041 Vim

04 May 2013

Vim is an extension of Vi editor, a powerful text editor used with much configurations and customisations among developers. With many keystrokes and shortcuts, we can achieve enchanced productivity given the high learning curve. In this episode we will review the basics of Vim with a simple outline of software design patterns.

Download video: mp4

Sample code: Github

Version: 7.3

Similar episodes: 002 Terminal, 008 Siblime Text

Background on Vim

  1. Main website
  2. [Wikipedia](http://en.wikipedia.org/wiki/Vim(texteditor))
  3. MacVim
  4. Git commit after merge opens VIM

Things to learn with Vim

1. download and open vim

  1. download or on a MAC OSX, just open the command line and type vim
  2. update the MAC OSX vim with MacVim
  3. go through the in-built vim tutor with vimtutor in the command line

2. basics

open your command line and note the folder path that you are in currently


  vim path/to/file/name

edit the file

save the file

quit with no changes

quit without saving change

quit and save

navigate through the file contents


cut copy paste

search and replace

access command line

3. layout



4. vim config

  1. the file resides in ~/.vimrc
  2. some common settings include:
  set nocompatible

  call pathogen#infect()

  syntax enable
  set number
  set incsearch
  set hlsearch
  set autoindent
  set smartindent
  set shiftwidth=2
  set guifont=Monaco:h25
  set fileencoding=utf-8
  set encoding=utf-8
  set ruler
  set hidden
  colorscheme solarized
  set tabstop=2
  set foldenable

5. macros

  1. start recording: qa, where a is the name of the macro
  2. stop recording: q
  3. view the registered commands: :reg
  4. start the macro: @a or repeat it 200@a, where a is the name of the macros

6. color scheme

  1. get current theme: :colo
  2. set current theme: :colo [tab] or :colo [theme]
  3. set light/dark options: :set bg=light

More Resources on Vim

  1. nano, pico and other command line text editors
  2. Mac Vim
  3. Just use Sublime Text
  4. How to set environment variables on MAC OSX Lion
  5. Vimcast
  6. Tutsplus Vim course

More resources on the project - design patterns

  1. Design Patterns by the gang of 4
  2. Design patterns book

Build Link of this episode

Podcasts for designers and developers! by Smashing Magazine