{"id":30212,"date":"2021-01-18T03:36:04","date_gmt":"2021-01-17T19:36:04","guid":{"rendered":"https:\/\/web.mwwsb.com.my\/pjci\/?post_type=kb&p=30212"},"modified":"2022-09-07T20:03:18","modified_gmt":"2022-09-07T12:03:18","slug":"overview-of-the-vim-text-editor","status":"publish","type":"kb","link":"https:\/\/www.casbay.com\/guide\/kb\/overview-of-the-vim-text-editor","title":{"rendered":"Overview of the Vim Text Editor"},"content":{"rendered":"\t\t
\n\t\t\t\t\t\t\t\t\t
\n\t\t\t\t\t\t
\n\t\t\t\t\t
\n\t\t\t
\n\t\t\t\t\t\t\t\t
\n\t\t\t\t
\n\t\t\t

Overview of the Vim Text Editor<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t

Many articles in this knowledge base advise editing configuration files. However, we usually recommend using the text editor which you prefer. At Liquid Web, we would recommend vim<\/a>. Vim, or its older sibling vi, are installed by default on nearly every server that we come across. If you do not yet have a text editor in your mind, read on to see if vim might work for you.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t

\n\t\t\t\t
\n\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\"Overview\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t

Vim Text Editor<\/em><\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t

\n\t\t\t\t
\n\t\t\t

1) Normal Mode<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
\n\t\t\t\t
\n\t\t\t\t\t\t\t

The biggest concept that beginning vim users need to know is the concept of\u00a0modes<\/em>. There are different editor functions, such as moving the cursor around and inserting text. We can accomplish them in different modes. Open up a file in vim:<\/p>

vim example.conf<\/code><\/p>

Then, you are immediately put into normal<\/strong>\u00a0mode. Normal modes does not seem normal at first. If you press \u201cj\u201d in normal mode, the letter \u201cj\u201d does not appear. Instead, the letter \u201cj\u201d moves the cursor down one line. Positioning the cursor in this mode is completely done with letter keys. The most basic are:<\/p>

  • j<\/strong>\u00a0\u2013 one line down<\/li>
  • k<\/strong>\u00a0\u2013 one line up<\/li>
  • h<\/strong>\u00a0\u2013 one character left<\/li>
  • l<\/strong>\u00a0\u2013 one character right<\/li><\/ul>

    While this may seem odd at first, switching from mode to mode actually speeds typing up. This means that you do not have to move your right hand over to the arrow keys. Moreover, you also do not need to move back every time you wish to reposition the cursor.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t

    \n\t\t\t\t
    \n\t\t\t

    2) Insert Mode<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\t\t

    To leave normal mode and start typing text, press \u201ci\u201d to enter\u00a0insert mode<\/strong>. Insert mode behaves much more like the default mode in other text editors. There should not be any surprises.
    When you are done with insert mode, hit the\u00a0ESC<\/strong>\u00a0key to get back to normal mode.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t

    \n\t\t\t\t
    \n\t\t\t

    3) Command-line Mode<\/h2>\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t
    \n\t\t\t\t
    \n\t\t\t\t\t\t\t

    Command-line mode is used to perform a wide range of commands. To enter vim\u2019s command line, hit \u201c:\u201d (the colon) in normal mode. This will drop the cursor to the bottom of the terminal. Here you can do things like:<\/p>

    • Save your changes (write)::w<\/code><\/li>
    • Quit out of vim::q<\/code><\/li>
    • Quit without saving changes::q!<\/code><\/li><\/ul>

      You can also combine commands to run them together. This is commonly done to save the file and quit vim at the same time:<\/p>

      :wq<\/code><\/p>

      After you have run a command, vim will place you back in normal mode.<\/p>\t\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t<\/div>\n\t\t\t\t\t\t\t<\/div>\n\t\t<\/section>\n\t\t\t\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"

      Overview of the Vim Text Editor Many articles in this knowledge base advise editing configuration files. However, we usually recommend using the text editor which you prefer. At Liquid Web, we would recommend vim. Vim, or its older sibling vi, are installed by default on nearly every server that we come across. If you do […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"page-builder","ast-site-content-layout":"","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","theme-transparent-header-meta":"default","adv-header-id-meta":"","stick-header-meta":"default","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-gradient":""}}},"kbtopic":[109],"kbtag":[106,105],"mkb_version":[],"_links":{"self":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/30212"}],"collection":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb"}],"about":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/types\/kb"}],"author":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/comments?post=30212"}],"version-history":[{"count":10,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/30212\/revisions"}],"predecessor-version":[{"id":38115,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kb\/30212\/revisions\/38115"}],"wp:attachment":[{"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/media?parent=30212"}],"wp:term":[{"taxonomy":"kbtopic","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtopic?post=30212"},{"taxonomy":"kbtag","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/kbtag?post=30212"},{"taxonomy":"mkb_version","embeddable":true,"href":"https:\/\/www.casbay.com\/guide\/wp-json\/wp\/v2\/mkb_version?post=30212"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}