Introduction to Vim Editor
Vim Editor is currently the most popular Unix based editor. 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 called a "programmer's editor," and so useful for programming that many consider it an entire IDE. It's not just for programmers, though. Vim is perfect for all kinds of text editing, from composing email to editing configuration files.
first you need to install vim : sudo apt-get install vim
The best way to learn vim is by use and not by
memorization. You need to practice the command instead of memorizing it. An
excellent first step would be to try the vimtutor.
There are mainly two modes in Vim:
Normal and not normal (Insertion, Visual, etc.). By default, it is normal mode.
Switch to insertion mode: i, or o, or a, or A
switch to visual mode: v
switch back to normal mode: <ESC>
:w Saving the current file
:q exit vim
:q! exit vim without saving
:e file : one another file
To move in the text:
arrows or j,k,h,l
e : to go to the end of a word
b : to the beginning of a word
0 : to the beginning of a line
$ : to the end of a line
:12 jumps to line 12
i : insert before cursor
a : append after cursor
A : appends at end of line
o: creates a new line and insert mode
O: creates a new line before
x: deletes the character under the cursor
dd: deletes the current line
visual mode + d: deletes the selected text
Copying text in Vim is called Yanking.
visual mode + y: copy (or yank) the selected text
yy copies the current line
p: put (paste) the yanked text.
/ : searches for a text
n : to go the next occurrence
:s/old/new/g : replaces old by new in all the file.
:sp to split the window
:sp file : to split the window between the current file and another file
:vs : split vertically
:e . open an integrated explorer (gf to open a file or enter a folder)
IMPORTANT: to have a practical introduction to vim, use the vimtutor:
type in vimtutor in a linux terminal and follow the instructions. It will take
you 30 minutes but it is really worth it.
List of books about Vim:
Must see:
vim tips wiki