Ben Congdon

Vim

Moving

  • z.: Scroll cursor to center of screen
  • zb: Scroll cursor to bottom of screen.
  • zt: Scroll cursor to top of screen.
  • <C-u>: Scroll up half a page
  • <C-d>: Scroll down half a page
  • %: Jump between matching brackets/parenthesis
  • { / } move between paragraphs.
  • gg / gG: Jump to beginning/ending of file.
  • gx: Open the URL (or file) under the cursor

Text Manipulation

  • S], S), S}: Surround selection with bracket.
  • D: Delete to end of line.
  • C: Change to end of line.
  • J: Join current line with next line.

Insert Mode

  • <C-r> {register}: Paste while in insert mode.
  • <C-o>: Exit insert mode to perform a single normal-mode action, return to insert mode.

Spell Check

  • ]s / [s: Go to next/previous misspelled word.
  • z=: Replace misspelled word under cursor.

Window/Tab Manipulation

  • :vsp - Vertical split
  • :sp - Horizontal split
  • :tabe - New tab
  • :only - Closes all but the current split
  • :tabonly - Closes all but the current tab
  • :xa - Save and close all open files

Buffers

  • enew - Opens a new, unnamed buffer. (Useful for making a scratch pad)

vim-go

  • gd - Go to function definition.

Text Objects

  • if/af - “In function”, “Around function”

Misc/Customizations

" Quickly open your vimrc in a new tab
nmap <leader>vimrc :tabe ~/.vimrc<cr>

" Reload your vimrc
nmap <Leader>r :source ~/.vimrc<cr>

" Paste on newline
nmap <Leader>p $p

" Copy full file path to the default register
nmap <Leader>yp :let @" = expand('%:p')<cr>

Advanced

Things I Still Need to Learn

  • Marks
  • Macros
  • Completions
  • Abbreviations

Other Resources

esc