- First make sure you don't have a
~/.vimdirectory or a~/.vimrcfile.
# if you want to backup
$ mv ~/.vim ~/.vim.bak
$ mv ~/.vimrc ~/.vimrc.bak
# otherwise just remove
$ rm -rf ~/.vim
$ rm ~/.vimrc
- Setup vimming.
$ git clone https://github.com/thisduck/vimming.git ~/.vim
$ cd ~/.vim
$ rake
- Open
vimand enjoy.
- make sure to get the latest version of vim for your respective system.
brew install vimon a mac, for instance.- also add
alias vi=vimto your~/.bashrcor~/.zsrhcfile. - also install the silver searcher:
brew install the_silver_searcheror the equivalent for your system.
- The leader key is the spacebar.
- tabstop/shiftwidth/softtabstop is 2
- Wherever I say "highlight" I mean Visual Mode.
- You can use
<C-c>for Esc. - When you split a window, it will appear below or to the right (for a vertical split).
- Search is using the_silver_searcher instead of grep.
K(shift + k) while on a word, will grep for the word in the code base.foo_barwill also findfoo_bar_something
KK(shift + kk) while on a word, will grep for the tag (just the word) in the code base.foo_barwill not findfoo_bar_something
<Leader>/will unhighlight the search terms.
:Gstatuswill display a window buffer with the git status.- If you place your cursor over a file and press Enter, it will open in the buffer above.
- If you place your cursor over a file and press
D, the diff of that file will be displayed. - If you place your cursor over a file and press
-, the file will be placed in staging (git add), or removed from staging if it was already there (git reset). :Gcommitwill open a window buffer where you can enter your commit message. Saving the message will commit the file.- You have access to git commands via
:Git:Git push origin master, for instance will push to master.
:Gdiffon a file with changes will open a diff buffer.- In order to revert changes, select the part of the code and use
:diffget, this will get the changes from the diff buffer. - If you're in the diff buffer and want the send the changes to your file,
:diffput.
- In order to revert changes, select the part of the code and use
:Gblamewill open a buffer indicating who commited that line.:Gbrowseopens the current file in Github.
- To see the buffer window:
<Leader>be(this will replace the current buffer) - To see the buffer window in a split:
<Leader>bsor<Leader>bv - You can navigate the buffer, press Enter on a file to open it.
<Leader>ywill copy things to your normal clipboard (you can paste on other programs).<Leader>yswill open a copy history for things you've yanked or deleted.- Press Enter on one to paste it.
- Use
<Leader>bto open a split buffer window of all the tags in this file.- Press Enter on any of the tags to go to them.
- Highlight some lines and press
\\to comment (and uncomment). \\\on a line without highlight to comment/uncomment.
<Leader>a=will align based on the equal sign.<Leader>a:will align based on the:.<Leader>a>will align based on the=>.<Leader>atwill align based on the|for tables.
Rails Plugin
gfover a class, partial, will take you to the file. (this will even work on symbols: withhas_many :users,gfon the:userssymbol will take you to the user model.:Rmodel <model_name>will take you to the model.- Similar things will happen for
:Rcontroller,:Rview - Try tab completion with the model names, it will show you possible options. Always search in lowercase.
:RVmodelwill open the model in a vertical split.:RSmodelin a horizontal split.:RVcontroller,:RVviewalso work.
- Similar things will happen for
- While in a controller method
:Rwill take you to the view of that method.:Rfrom the view will bring you back to the method.:RV,:RSwill open in splits. - While in a model
:Awill take you to the tests. - In general
:Awill take you to an alternate file.:Rwill take you to a related file. Play around with these in different files.