Tutorial by Examples

Add this to your vimrc: nnoremap Q @q To start recording the "throwaway" macro, use qq. To finish recording hit q (in normal mode for both). To execute the recorded macro, use Q. This is useful for macros that you need to repeat many times in a row but won't be likely to use again af...
This is very common, you memorize a path to a file or folder, you open up Vim and try to write what you've just memorized, but you are not 100% sure it's correct, so you close the editor and start over. When you want the path completion feature, and you have a file /home/ubuntu/my_folder/my_file a...
To delete some lines of text when you don't know exact number of lines to delete, you try 10dd , 5dd , 3dd until you remove all the lines. Relative line numbers solves this problem, suppose we have a file containing : sometimes, you see a block of text. You want to remove it but you cannot d...
To view line numbers from Default view enter :set number To hide line numbers :set nonumber There is also a shortcut for above. nu is same as number. :set nonu To hide line numbers, we can also use :set nu!
A lot of Vim users find the Esc too hard to reach, and end up finding another mapping that's easy to reach from the home row. Note that Ctrl-[ may be equivalent to Esc on an English keyboard, and is much easier to reach. jk inoremap jk <ESC> This one is really easy to trigger; just smash...
To know the path of the directory your file is in you can use: Esc to enter command mode :pwd This will print the path to the directory at the bottom of the editor, like this I'm a ninja ~ ~ ~ ~ ~ /home/ubuntu/myfolder 1,5 All Now...
To search for text foo within a {} block surrounding the cursor use the following command (<ESC> - escape key, <CR> - enter key) : vi{<ESC>/\%Vfoo<CR> now you can jump between the matches within the block by pressing n and p. If you have hlsearch option enabled this will ...
A lot of users find themselves in a situation where they just want to copy, move or delete a line quickly and return to where they were. Usually, if you'd want to move a line which contains the word lot below the current line you'd type something like: /lot<Esc>dd<C-o>p But to boost...
This command will save the open file with sudo rights :w !sudo tee % >/dev/null You can also map w!! to write out a file as root :cnoremap w!! w !sudo tee % >/dev/null
To automatically reload vimrc upon save, add the following to your vimrc: if has('autocmd') " ignore this section if your vim does not support autocommands augroup reload_vimrc autocmd! autocmd! BufWritePost $MYVIMRC,$MYGVIMRC nested source % augroup END endif a...
set wildmenu to turn on completion suggestions for command line. Execute the following set wildmenu set wildmode=list:longest,full Now if you do say, :colortab, You'll get 256-jungle Benokai BlackSea C64 CandyPaper Chasing_Logic ChocolateLiquor :color 0x7A69_dark

Page 1 of 1