Yet Another Vim Tricks

As I mention on my previous post, Vim is simple but powerful editor. There are so many shortcuts, key combinations and tricks to perform a better experience.  As I am still learning to be familiar with Vim, so I write this post to remind me about several cool tricks of Vim.

*

Search for all occurrences of word under the cursor.

cw

Change word under cursor

ci"

Delete everything inside “” string and start insert mode

Ctrl-c

Quit Insert mode (sometime, faster than ESC)

:earlier 15m

Reverts the document back to how it was 15 minutes ago. Can take various arguments for the amount of time you want to roll back, and is dependent on undolevels. Can be reversed with the opposite command :later

=%

Indents the block between two braces

.

Repeat previous command

"*

Accessing windows clipboard buffer

:up

Saves the current buffer if it has been modified

:TOhtml

Export current document as HTML formatted

:sort

Sort a selection of text or an entire whole file

\be

Builtin buffer explorer

:.!
:r!

Dump the output of the command into your current document

:%s/old/new/igc

Perform replace all

q:

Look at your :[command] history

:retab

Convert tabs to spaces

There are another super awesome vim tricks that you can read here and here. Also read Vim Recipes that freely available on various formats.



Share and Bookmark


Leave a Reply