Upgrade to Pro — share decks privately, control downloads, hide ads and more …

A Quick Primer on Vim

A Quick Primer on Vim

James Cox

March 19, 2012
Tweet

More Decks by James Cox

Other Decks in Programming

Transcript

  1. Starting with Vim Get it at http://code.google.com/p/macvim/ Clone someone’s vim

    dotfiles. Mine: https://github.com/imajes/vimfiles Sam’s: https://github.com/idoru/idoru-vim-config Install Macvim cli helpers. Monday, March 19, 12
  2. Vim is modal Insert (for typing) Normal (editing, moving, changing

    text/structure) Visual (selecting text) Command (running commands. duh.) Monday, March 19, 12
  3. Key Mode Operators Bare letters to change mode (e.g. i

    for insert) Backslash to execute searches Forward slash for leader (default, can be remapped) Colon for commands (e.g. :wq for save, quit) Monday, March 19, 12
  4. Basic Navigation h,l,k,j (left, right, up line, down line) ^

    - first character (or, ctrl-a on OS X) $ - last character (or, ctrl-e on OS X) cursor keys. (ignore the purists) G, <n>G (go to line, go to numbered line) Monday, March 19, 12
  5. Opening Files vim <path/to/file> - open a file :tabe <path/to/file>

    - to open a file in a tab :split <path/to/file> - open a file and split with the current :vsplit <path/to/file> - open a file and vertical split with current Monday, March 19, 12
  6. Quitting The Buffer :q - quit :q! - force quit.

    :) Usual behavior: :wq Monday, March 19, 12
  7. Fun Stuff :ct <char> - Cut to character, also: :yt,

    :dt :%s/a/b/ - Buffer search and replace :noh - remove highlights which are annoying gt/gT - move between tabs Monday, March 19, 12
  8. Plugins: Gist Source - http://www.vim.org/scripts/script.php? script_id=2423 (drop this in your

    plugins dir) Be careful of settings: let g:gist_clip_command = 'pbcopy' let g:gist_open_browser_after_post = 1 let g:gist_detect_filetype = 1 Monday, March 19, 12
  9. Plugins: Fugitive Tim Pope - https://github.com/tpope/vim-fugitive Git wrapper. Git activities

    in hackable buffers = awesome Fave tool: :Gblame Monday, March 19, 12
  10. Pairing with vim Vim is a serious text editor. In

    the way that Schubert has a serious movember ‘tache. Pairing is fine, but I think it makes sense to only have one driver at a time - it’s hard to ‘share’ typing. A common env is not impossible but it’s definitely ‘personal’ - fortunately it’s easy to switch ~/.vim Monday, March 19, 12
  11. Pontifications Vim is easy enough to learn if you’re willing

    to spend two weeks looking at a cheat sheet or bugging someone - or pair with someone. Textmate hasn’t changed significantly in forever, we all know it’s failings. Old and creaky. Rubymine takes 6 weeks to boot. Emacs. sigh, Godwin’s law, you win. Monday, March 19, 12