17
Vim Notes James Cox, smokeclouds Tuesday, November 23, 2010

Vim Notes

Embed Size (px)

DESCRIPTION

Getting started with the text editor vim- some notes and ideas about vim agile and what not

Citation preview

Page 1: Vim Notes

Vim NotesJames Cox, smokeclouds

Tuesday, November 23, 2010

Page 2: Vim Notes

Starting with Vim

Get it at http://code.google.com/p/macvim/

Clone someone’s vim dot!les.

Mine: https://github.com/imajes/vim!les

Sam’s: https://github.com/idoru/idoru-vim-con!g

Install Macvim cli helpers.

Tuesday, November 23, 2010

Page 3: Vim Notes

Vim is modal

Insert (for typing)

Normal (editing, moving, changing text/structure)

Visual (selecting text)

Command (running commands. duh.)

Tuesday, November 23, 2010

Page 4: Vim Notes

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)

Tuesday, November 23, 2010

Page 5: Vim Notes

Basic Navigation

h,l,k,j (left, right, up line, down line)

^ - !rst 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)

Tuesday, November 23, 2010

Page 6: Vim Notes

Opening Files

vim <path/to/!le> - open a !le

:tabe <path/to/!le> - to open a !le in a tab

:split <path/to/!le> - open a !le and split with the current

:vsplit <path/to/!le> - open a !le and vertical split with current

Tuesday, November 23, 2010

Page 7: Vim Notes

Writing (Saving) files

:w (existing)

:w <path/to/save> (new)

:w! forces it

Tuesday, November 23, 2010

Page 8: Vim Notes

Quitting The Buffer

:q - quit

:q! - force quit. :)

Usual behavior: :wq

Tuesday, November 23, 2010

Page 9: Vim Notes

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

Tuesday, November 23, 2010

Page 11: Vim Notes

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_!letype = 1

Tuesday, November 23, 2010

Page 12: Vim Notes

Plugins: Endwise

Tim Pope’s - https://github.com/tpope/vim-endwise

‘Wisely’ adds an ‘end’ where appropriate

Tuesday, November 23, 2010

Page 13: Vim Notes

Plugins: Fugitive

Tim Pope - https://github.com/tpope/vim-fugitive

Git wrapper.

Git activities in hackable buffers = awesome

Fave tool: :Gblame

Tuesday, November 23, 2010

Page 14: Vim Notes

Plugins: Rails

Oh, Tim Pope. https://github.com/tpope/vim-fugitive

Where might one begin?

Tuesday, November 23, 2010

Page 15: Vim Notes

Pairing with vim

Vim is a serious text editor. In the way that Schubert has a serious movember ‘tache.

Pairing is !ne, 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 de!nitely ‘personal’ - fortunately it’s easy to switch ~/.vim

Tuesday, November 23, 2010

Page 16: Vim Notes

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 signi!cantly in forever, we all know it’s failings. Old and creaky.

Rubymine takes 6 weeks to boot.

Emacs. sigh, Godwin’s law, you win.

Tuesday, November 23, 2010