Some useful vim tips and cheat sheet

Written on 17 July 2015

Some vim tips I have mostly used.

1. Set language syntax highlighting

:setf  language

Example: :setf c, :setf java, :setft javascript

2. Show line number

:set nu  

3. Delete in insert mode 1

<C-h> " delete back one character (backspace)  
<C-w> " delete back one word  
<C-u> " delete back to start of line  
<C-k> " delete forward to end of line  

4. Copy and paste in vim editor2

y<mov. comm>  Yank a movement into buffer (copy).  
yy Yank the whole line.  
p   Insert the yanked text at the cursor.  
P Insert the yanked text before the cursor.

5. Delete to the end of line

Shift + d or d + $

6. Insert timestamp

:r! date

Sample output

Tue Jul 21 17:04:25 IDT 2015

Vim Cheat Sheet

Vim Cheat Sheet Printable Vim Cheat Sheet Printable Vim Cheat Sheet Printable PDF file http://locobox.googlepages.com/vi-vim-cheat-sheet-qwerty.pdf