Vim Configuration


About a year ago I finally bit the bullet and commited to learning a real text editor. I went with Vim. Once you break through its initial steep learning curve, its truly life changing. Your text editing skills will improve a few orders of magnitude. Level up from a text janitor to text surgeon today.

I usually clone my scripts git repo straight into my home directory i.e. ~/git/scripts/linux/vim. A couple of symlinks later, I’m away:

ln -nfs ~/git/scripts/linux/vim/vimrc ~/.vimrc
ln -nfs ~/git/scripts/linux/vim ~/.vim

Vim has brilliant built-in help. Its only one :help away.

Vim is very customisable. Its important to craft your own .vimrc. Type :options to understand the various levers you can pull to make Vim your editor.

Text Selection

  • To select a word aw (a word) or iw (inner word)
  • To select a sentence as (a sentence) or is (inner sentence). See the pattern here.
  • To select a paragraph ap or ip
  • A block a], a[, i], i[
  • A block (parentheses) a)

File navigation

This is important to me. Coming from powerful IDE’s like IntelliJ or Resharper, in order to be remotely productive, I need to be able to efficiency locate and jump between files within a large code base.

Thankfully the community has stepped in here.

  • NERDTree add’s a visual file system based tree.
  • CtrlP my personal favourite, for text based fuzzy file, buffer, MRU file navigation. Its pure Vimscript so very portable.

Windows

Its kind of amazing how Vim just seems to pull this off with effortless ease.

Nifty windowing commands:

  • Ctrl-w o - close all windows other than the active one.
  • Ctrl-w x - exchange active window with the next one.
  • Ctrl-w c - close the current window.
  • Ctrl-w r (R) - rotate windows clockwise (or counter clockwise).

You can get into how Vim determines what specific size to make windows when splits occur. See help and window-resize for more details.

relativenumber

Makes line numbering relative. So good! Makes it fast to figure out how many lines up or down you need to move, to get to the line you want.

  2 I usually clone my `scripts` git repo straight into my home
  1 ¬                                                          
13      ln -nfs ~/git/scripts/linux/vim/vimrc ~/.vimrc¬        
  1     ln -nfs ~/git/scripts/linux/vim ~/.vim¬                
  2 ¬                                                          
  3 Vim has brilliant built-in help. Its only one `:help` away.