The Vim Editor

Written on March 17, 2015
Estimated reading time : 3 mins
Tags : | shell | vim |

A long time back, I had conducted an interview in which I had asked “What tool do you use to edit PHP files ?”. The candidate had replied “vim”. I was impressed with his answer. However at that point in time, I didn’t know how powerful vim actually could be. This research is dedicated to vim.

About

  • The Vim editor started as “Vi IMitation” on the Amiga family of computers in 1988, but was later relabeled “Vi IMproved”
  • Since its first release for Unix systems in 1992, Vim has effectively eclipsed the original Vi, having won several awards and has been referred to as one of the most popular text editors.

Basics : Modes

Vim Modes

Basics : Commands

  • Mode Switching :
    • Esc
    • i
  • Search :
    • / & ? & \c
    • n - Search as per cmd order
    • N - Seach Backward as per cmd order
  • Search & Replace :
    • %s/old/new/gc
  • Delete
    • d
  • Plugin Manager
    • Plugin managers have evolved as : Pathogen -> Vundle -> NeoBundle
    • The plugin managers listed above are all active & have legions of followers. For my part - I adopted the one which I found to be most active : Neobundle.
    • Not necessary to install it but makes things easier to manage.
    • Creates the directory ~/.vim/bundle, with a separate subdirectory for all the files of each extension. This structure allows users to easily and thoroughly delete extensions, either manually or via a file manager, and helps minimize potential conflicts when you have a couple of dozen extensions.
    • Installation :
  • Themes
    • Gives themes to the Vim Editer & makes it more easy on the eye
    • Installation via NeoBundle :
      /* save below line in .vimrc file */
      NeoBundle 'bling/vim-airline'
      /* Enter vim via the shell */
      vim 
      /* Install desired bundles*/
      :NeoBundleInstall
    
  • Syntastic
    • Syntax Checking after saving the file via the Vim Editor
    • Installation via NeoBundle :
      /* save below line in .vimrc file*/  
      NeoBundle 'scrooloose/syntastic'
      /* Enter vim via shell */
      vim
      /* Install desired bundles */
      :NeoBundleInstall
    
  • Fugitive
    • Ability to execute git commands on the file via the Vim Editor
    • Installation via NeoBundle :
      /* save below line in .vimrc file*/
      NeoBundle 'tpope/vim-fugitive'
      /* Enter vim via shell */
      vim
      /* Install desired bundles */
      :NeoBundleInstall
    
  • Nerd Tree
    • Allows parallel browsing of folders from inside the Vim Editor
    • Installation via NeoBundle :
      /* save below line in .vimrc file*/
      NeoBundle 'scrooloose/nerdtree'
      /* Enter vim via shell */
      vim
      /* Install desired bundles */
      :NeoBundleInstall
    

References





Feel free to share this article :

submit to reddit

Add your thoughts, questions, doubts, suggestions as comments below :