On your terminal run the following commands to install and setup VIM:
chmod +x setup.sh
sudo ./setup.sh
Often more than not, people who tend to hate vim are either reluctant to learn and memorize the commands, largely because that seems too much and in other cases there is no proper documentation about it.
It is highly recommended to go through the help manual from the vim. It has all the essential commands, from beginner to advanced. However, some commands are already described below, which are used most frequently while coding.
:tabnew
starts a new tab with specified file or an empty file if not specified.:tabn
switches to a new tab.:split
does a horizontal split of the screen. With the same file or with different file if specified.:vsplit
works same like split except does a horizontal split.c
is a cut specifier which can be later used withw
or other commands. Note the command after execution directs user into insert mode.C
deletes a current line and directs you to insert mode.^
is used to send cursor to the start of the line.$
sends the cursor to the end of the line.A
appends likea
but at the end of the current line.I
goes to the beginning of the line.m + [letter]
bookmarks a line with that letter.' + [letter]
can be used to navigate to that line later. Can be used while working with big code where you want to locate to same function every time you open a file. You can check marks details by using:marks
.<<
or<j
is used to indentation to the left.:[range]<
shifts the indent for the range of line numbers.>>
or>j
is used to indentation to the right.:[range]>
shifts the indentation for the range of line numbers.==
or=j
is used to properly indentation.:[range]=
indentation the lines properly for that particular range.~
is used to change the case of the character under cursor./[search]
searches for the pattern inserted.d[modifier]
modifies the delete pattern. For example,d4w
deletes 4 words following the cursor.cc
changes a whole line. It directs you to insert mode automatically..
repeat a change. That is, for example, if you find a word like four and say want to change it to five then after doing the first change, navigating to the word and using the mentioned command will do the job. The change gets implemented even for any word.daw
deletes the word regardless of the position of the cursor in that word. More precisely, "daw" can be attributed as "delete a word".cis
similar todaw
deletes a whole line in a paragraph. This helps in line in a bunch of lines which might become a headache otherwise.:set spell
does a spell of every word while typing.]s or [s
takes you to forward or misspelled word and backward of misspelled word.z=
takes you to the suggestions of the word.zg
adds the word to the dictionary.zug
removes the added word to the dictionary.zw
adds a word to the wrong or bad word list.zuw
removes the word from the wrong word list.- Press v to enter into visual mode. Then go over to the file to select text and yank it.
^
is used for the beginning of the line. Thus if the pattern is to be searched for the beginning of every line^[pattern]
. For example,^the
searches for the word "the" at the beginning of every line.$
is used for the end of the line. Thus, if the pattern is to be searched for the end of every line[pattern]$
is used. For example,the$
will search for the word the at the end of every line..
matches any character. For example,/c.m
will search for the 3 letter word which starts with "c" and ends with "m" and can have any character in place of.
[ctrl] + o
and[ctrl] + i
is used for jumping inside a file. Intuitively to remember, "o" stands for older and "i" is just beside "o"./\c[pattern]
ignores the case of the characters in the pattern. Thus for a pattern "the", it matches "The", as well as "THE" and other combinations.