Date: 2013-11-11 Title: My vimrc documentation
git clone git@github.com:martinos/dotvim.git ~/.vim
ln -s ~/.vim/vimrc ~/.vimrc
ln -s ~/.vim/gvimrc ~/.gvimrc
:sp .
:vs .
Horizontal split view:
:Sex
Vertical split view:
:Vex
- %: create a file
- d: create a directory
- R: rename a file
- <c-t>: Open in new tab
- <c-x>: Open in horizontal split
- <c-v>: Open in vertical split
- <c-y>: Create a new file
- <c-j> or <c-k>: Move up and down
To toggle characters
xp
To toggle lines
ddp
List buffers:
:ls
Next buffer:
:bn
Open buffer N in horizontal split:
:sbuffer N
Open buffer N in vertical split:
:vert sb N
To list all register:
:reg
- "": default register
- "0: yank register
- "\_: black hole register
- "*: Copy to the local clipboard
The yank register, as it's name says it contains the last yanked register. This buffer is not replaced by the deleted lines or character
We can append to a register by using the capital version of the register
"Ayy
To reset a register
qaq
To open the quick fix window.
:copen
To go to the previous/next element in the quick fix :cnext :cprev
To facilitate navigation into the quick fix, you can use the unimpaired.vim plugin
Unimpaired |Vim |Action
[q :cprev jump to previous quickfix item
]q :cnext jump to next quickfix item
[Q :cfirst jump to first quickfix item
]Q :clast jump to last quickfix item
:Gstatus
CTRL-N : Go to next file
CTRL-P : Go to previous file
- key : Add file to the index when not staged
: Remove the file from the index. git reset equivalent
SHIFT-c : Open the commit window
:Gdiff
The index is on the left window
The working copy is on the right window
:Gwrite in the working copy window write the content of the file to the index
:Gwrite in the index window, writes the content of the file to the working copy
:Gread is the inverse of Gwrite
:diffget
From the index it gets the hunk from the working copy to the index.
:diffupdate
Refresh the diff windows when vim is confused
do
Diff optain, when you type 'do' at the end of block that is not existing on the index.
Go to a definition. Memo trick: you go into the cave.
ctrl-]
Get out of a definition. Memo trick: you get out of the cave.
ctrl-O
:tag method_name_to_acces
:tag /validates_presence_of_.* # It can accept regular expression.
:Rfind event # You can tab and it will iterated through mondels controllers helper etc.
gf # Go to file under the cursor,
# it works for active record relation
# partials, routes and even url helpers
:RVunittest # Opens the unit test in a vertical split
:RSunittest # Opens the unit test in a horizontal split
:RTunittest # Opens the unit test in a new tabs
:Rake # Run the current test
:Rgenerate migration add_coco_to_foo
:A opens alternate file :A opens alternate file in a horizontal split :Av opens alternate file in a vertical split
Print the list where the
:jumps
To jump back to the last jump
C-O # Go out of a jump
C-I # Jump in
Snippets location: ~/.vim/snippets
http://usevim.com/2013/03/01/vim-101-text-objects-for-html/
dit => delete inner tag cit => change inner tag yit => yank inner tag vit => visual inner tag
dat => delete a tag
To swap the two buffers:
Ctrl-w r
ci" # Change inside "
da" # Delete a around "
gi # Return back to last insertion location
To reload vimrc :so %
https://www.youtube.com/watch?v=dB2Q9EN37eY
https://github.com/Lokaltog/vim-easymotion
<leader> sbp => Prompt for profile
<leader> se => Execute under cursor
<leader> slt => List all tables
<leader> sdt => Describe table column
<leader> slc => Create an alias for the table under cursor.
List the columns with the alias in the yank buffer.
R in the result buffer: Refreshes the buffer