At least once each semester, as I save my notes and pack up my laptop after class, someone asks me, “What program do you use to take notes?”
I don’t use anything fancy: it’s just a dark background with monospaced, technicolor, plain text. Yes, I use Vim.
Actually, to be more precise, I use MacVim, a gVim clone built to run in Mac OS X.
What is Vim?
Unless the course is a computer science topic, this is often the next question I am asked.
Vim is a powerful, modal 1, all-purpose, command-line text editor. It’s name stands for Vi IMproved because is based on the vi editor, which was written in 1976 and improved upon ex (also written in 1976), which in turn was an advanced version of ed (written in 1971). Thus one could argue that Vim is over 40 years old.
I keep notes in a personal Wiki, so all of my notes are in plain-text MediaWiki format.
The distraction-free environment and keyboard-based commands make navigating, editing, and writing faster and feel more fluent: No more fooling around with the cursor or arrow keys and then repositioning my hands on the keyboard.
Plugins and macros (see below) make editing much faster and prettier. The technicolor text comes from the MediaWiki syntax definition.
Transcribing Wiki-markup from files into the web browser is a great study aid.
Stability (this is the main reason). Vim is an old editor, so they’ve had time to work the kinks out, making it more stable than other text editors. Simple text editors (and web browsers, for that matter) crash, and when they do, they tend to lose data. On the off chance that Vim crashes, all session information is maintained in the
Appendix 1: My Favorite Vim plugins
- Pathogen: modularize Vim plugins into separate directories (makes plugin organization much easier).
- Command-T: TextMate, Sublime Text, Eclipse—they all have a way to open (go to) files quickly.
- Surround: add, modify, and delete matching delimiters (such as parentheses, quotes, HTML tags, etc.).
- Gundo: Vim has the coolest undo history, but it can be difficult to navigate. Gundo is a graphical representation that makes it easy.
- Tabular: Automatically align text.
- NERD Tree: A file explorer replacement.
- Indent Guides: visual aids to identify indentation levels.
- Trailer Trash: Find and remove trailing whitespace.
- CSS Color: Preview colors in CSS files.
- XPTemplate: Expandable snippets for repetitive patterns in code.
- Sensible: sets most of the options in my
.vimrcbelow (Lines marked with
[*Sensible]can be dropped if Sensible is installed.
- Syntax and language definitions for CoffeeScript, CSS3+SCSS, EBNF, Haml, Jade, LESS, Markdown, MediaWiki, YAML, and Zen Coding.
Appendix 2: My
Many users publish their
.vimrc configuration to share some of their workflow shortcuts, so here’s mine. Most of the stuff in here is probably borrowed from other people anyway, so a big thank you to them!
set nocompatible " We're using VIM, not VI " ============================ " Pathogen Bundle Management " ============================ runtime bundle/pathogen/autoload/pathogen.vim call pathogen#infect() " ==================== " Editor Preferences " ==================== syntax on filetype plugin indent on " load ftplugin and indentation files set smarttab " [*Sensible] set autoindent " [*Sensible] Auto-indent set smartindent " Smart-indent set tabstop=8 " Tab literals are 8 spaces wide set shiftwidth=4 " Soft tabs are 4 spaces wide set softtabstop=4 " Backspace acts like unindent set expandtab " Insert spaces instead of tabs set listchars=tab:▸\ ,eol:¬ " [*Sensible] Show whitespace chars set showmatch " [*Sensible] Highlight matching delimiters set mat=2 " [*Sensible] Show matchng delimiter for .2sec set nowrap " do not wrap text in display if exists("&rnu") set rnu " Relative line numbering (if available) else set number " Line numbers endif set ruler " [*Sensible] Show position in bottom-right set showcmd " [*Sensible] Show incomplete commande as you type set magic " Pattern matching with special chars set incsearch " [*Sensible] Make search act like a browser set hlsearch " Highlight search results set backspace=eol,start,indent " [*Sensible] set whichwrap+=<,>,h,l set autochdir " Automatically set browser to working dir silent! colorscheme komputerwiz " Custom colorscheme, based heavily on 'slate' let map leader = '\' " '\' by default, but can't use multichar maps " ================ " Spell Checking " ================ nmap <silent> <leader>s :set spell!<CR> set spelllang=en_us " ========= " Folding " ========= set foldmethod=syntax set foldcolumn=4 " ====== " gVim " ====== if has('gui_macvim') set guifont=Ubuntu\ Mono:h11 elseif has('gui_running') set guifont=Ubuntu\ Mono\ 11 endif if exists("&guioptions") set guioptions-=T " Hide toolbar by default " Hide scrollbars by default set guioptions-=r " right scrollbar set guioptions-=R " right scrollbar (vsplit) set guioptions-=l " left scrollbar set guioptions-=L " left scrollbar (vsplit) set guioptions-=b " bottom scrollbar " mappings to toggle gui elements nmap <D-\> :if &go=~#'T'<Bar>set go-=T<Bar>else<Bar>set go+=T<Bar>endif<CR> nmap <leader>R :if &go=~#'r'<Bar>set go-=r<Bar>else<Bar>set go+=r<Bar>endif<CR> nmap <leader>L :if &go=~#'l'<Bar>set go-=l<Bar>else<Bar>set go+=l<Bar>endif<CR> nmap <leader>B :if &go=~#'b'<Bar>set go-=b<Bar>else<Bar>set go+=b<Bar>endif<CR> endif " =========================== " Mappings and Key Bindings " =========================== nnoremap nnoremap <leader>l :set list!<CR> nnoremap <leader>v :tabedit $MYVIMRC<CR> " opening and closing folds quickly nnoremap <space> za vnoremap <space> za " text bubbling (unimpaired remappings) nmap <A-D-Up> [e vmap <A-D-Up> [egv nmap <A-D-Down> ]e vmap <A-D-Down> ]egv " type '\a' followed by '|', ':', or '=' to tabularze at that char if exists(":Tabularize") nmap <leader>a| :Tabularize /|<cr> vmap <leader>a| :Tabularize /|<cr> nmap <leader>a= :Tabularize /=<cr> vmap <leader>a= :Tabularize /=<cr> nmap <leader>a: :Tabularize /:\zs<cr> vmap <leader>a: :Tabularize /:\zs<cr> nmap <leader>a, :Tabularize /,\zs<cr> vmap <leader>a, :Tabularize /,\zs<cr> endif " map NERDTree toggle to <F3> map <F3> :NERDTreeToggle<CR> " map <F4> to run build and display errors nmap <F4> :w<CR>:make<CR>:cw<CR> " map <F5> to graphcal undo tree nmap <F5> :GundoToggle<CR> " ======================================================= " Set tabstop, softtab, and shiftwdth to the same value " ======================================================= command! -nargs=1 Stab call Stab(<f-args>) function! Stab(width) if a:width > 0 let &l:sts = a:width let &l:ts = a:width let &l:sw = a:width endif endfunction " ==================================== " Autosource vimrc when it's updated " ==================================== if has("autocmd") autocmd BufWritePost .vimrc source $MYVIMRC endif " ======================================== " vim -b : edit binary using xxd-format! " ======================================== augroup Binary " remove all autocmds for group 'Binary' au! au BufReadPre *.bin let &bin=1 au BufReadPost *.bin if &bin | %!xxd au BufReadPost *.bin set ft=xxd | endif au BufWritePre *.bin if &bin | %!xxd -r au BufWritePre *.bin endif au BufWritePost *.bin if &bin | %!xxd au BufWritePost *.bin set nomod | endif augroup END
Vim is modal because it has different “modes” for inserting text, entering commands, and selecting text. ↩︎