Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor distributed with most UNIX systems.
Vim is often used by programmers on Linux. But it can be used on Mac OS X and Windows too.
Vim is a powerful text editor that runs in a terminal, yet can be used to edit any kind of file. It's old, it's weird, and it's hard to learn but also one of the most powerful tools for editing code on any operating system.
So what about commands?
Here's a handy cheat sheet to help you get started with the editor.
|h||move cursor left|
|j||move cursor down|
|k||move cursor up|
|l||move cursor right|
|w||jump forwards to the start of a word|
|b||jump backwards to the start of a word|
To write and to use commands press
ESC for command mode or
i for insert mode.
To save, open and quit a file:
|Basic editor commands|
|:e filename||edit a file in a new buffer|
|:w||write (save) the file, but don't exit|
|:wq||write (save) and quit|
|:x||write (save) and quit|
|:q||quit (fails if there are unsaved changes)|
|:q!||quit and throw away unsaved changes|
|:qa||quit all buffers and windows|
|ZZ||write (save) current file, if modified, and quit|
|ZQ||quit without checking for changes|
You can copy and paste text too:
|Cut and Paste|
|yy||yank (copy) a line|
|2yy||yank (copy) 2 lines|
|p||put (paste) the clipboard after cursor|
|P||put (paste) before cursor|
|dd||delete (cut) a line|
|2dd||delete (cut) 2 lines|
There are quite a few commands you have to memorize to use Vim effectively, which can be overwhelming when you’re learning.
You can use these exercises to memorize commands.