-
The cursor is moved using either the arrow keys or the hjkl keys. h (left) j (down) k (up) l (right)
-
To start Neovim from the shell prompt type:
$ nvim FILENAME
-
To exit Neovim type:
<Esc>
{normal}:q!
{vim}<Enter>
{normal} to trash all changes. OR type:<Esc>
{normal}:wq
{vim}<Enter>
{normal} to save the changes. -
To delete the character at the cursor type:
x
{normal} -
To insert or append text type:
i
{normal} insert text<Esc>
{normal} insert before the cursor.A
{normal} append text<Esc>
{normal} append after the line.
NOTE: Pressing <Esc>
{normal} will place you in Normal mode or will cancel
an unwanted and partially completed command.
-
To delete from the cursor up to the next word type:
dw
{normal} -
To delete from the cursor to the end of a line type:
d$
{normal} -
To delete a whole line type:
dd
{normal} -
To repeat a motion prepend it with a number:
2w
{normal} -
The format for a change command is:
operator [number] motion
where:
operator - is what to do, such as [d](d) for delete [number] - is an optional count to repeat the motion motion - moves over the text to operate on, such as: [w](w) (word), [$]($) (to the end of line), etc.
-
To move to the start of the line use a zero: 0
-
To undo previous actions, type:
u
{normal} (lowercase u) To undo all the changes on a line, type:U
{normal} (capital U) To undo the undo's, type:<C-r>
{normal}
-
To put back text that has just been deleted, type p. This puts the deleted text AFTER the cursor (if a line was deleted it will go on the line below the cursor).
-
To replace the character under the cursor, type r and then the character you want to have there.
-
The change operator allows you to change from the cursor to where the motion takes you. Type
ce
{normal} to change from the cursor to the end of the word,c$
{normal} to change to the end of a line, etc. -
The format for change is:
c [number] motion
-
<C-g>
{normal} displays your location and the file status.G
{normal} moves to the end of the file. numberG
{normal} moves to that line number.gg
{normal} moves to the first line. -
Typing
/
{normal} followed by a phrase searches FORWARD for the phrase. Typing?
{normal} followed by a phrase searches BACKWARD for the phrase. After a search typen
{normal} to find the next occurrence in the same direction orN
{normal} to search in the opposite direction.<C-o>
{normal} takes you back to older positions,<C-i>
{normal} to newer positions. -
Typing
%
{normal} while the cursor is on a (,),[,],{, or } goes to its match. -
To substitute new for the first old in a line type
:s/old/new
To substitute new for all 'old's on a line type
:s/old/new/g
To substitute phrases between two line #'s type
:#,#s/old/new/g
To substitute all occurrences in the file type
:%s/old/new/g
To ask for confirmation each time add 'c'
:%s/old/new/gc