vim is "Vi improved"
- First Full-screen text editor written for Unix
- Designed to be small and simple
- Multi level undo/redo
- Extensible with plugins
- Can run in GUI
- Support for programming languages and file formats
## TO show Diff between Vim and Vi ##
:h vi-differences
Vim has 12 different editing modes, 6 of which are variants of the 6 basic modes.[34] The most important modes are:
## to list all modes info ##
:h vim-modes
-
- used for editor commands. This is also the default mode, unless the insertmode option is specified.
press ESC from other modes to enter normal mode
- Generally used for reading a file
- Accepts "invisible Commands"
-
- similar to normal mode, but used to highlight areas of text. Normal commands can be run on the highlighted area, for instance to move or edit a selection.
Enter Visual mode with v from Normal mode.
- Used for Applying commands on selection of text.
- Similar to clicking amd dragging with a mouse to highlight text.
- ESC to Normal mode.
-
- similar to editing in most modern editors. In this mode, buffers can be modified with the text inserted.
Press i to enter insert mode
- Used to edit text normally in this mode.
- ESC to Normal mode.
-
- supports a single line input at the bottom of the Vim window. Normal commands (beginning with :), and some other keys for specific actions (including pattern search and the filter command) activate this mode. On completion of the command, Vim returns to the previous mode.
Press : to enter Command-line mode from normal mode
- USed to modify settings, save or quit the file.
- Perform search or replace pr help.
- ESC to normal mode.
-
Open a file with vim
vim fileName.extension
-
Quit file
Press : to enter Command-line mode. Press q to Quit
-
To insert
Press i to enter insert modes
-
quit a file without saving ```Press :q!````
-
Save a file
:w // saves the file :w newfileName // makes a copy of the file :wq //save and quit the file :zz // save if changed and quit
-
Move around in vim
- use arrow keys
- use H J K L (left down up right)
- Goto end of the line
$
- Beginning of the line
0
- Forward a word
w
- Backward a word
b
- Bottom of the file
G
- Top go the file
gg
-
Line Numbers USeful for debugging scripts or errors
- Enable line numbers
:set number
- Disable line numbers
:set nonumber
- Goto specific line
:<linenumber></linenumber>
- Enable line numbers
-
Enable Mouse
:set mouse=a
-
Enter insert mode before cursor
Press i
-
Enter insert mode after cursor
Press a
-
insert new line below
Press o
-
Delete character
x
-
Delete five character
5x
-
delete line
dd
-
delete two lines
2dd
-
Delete from cursor to
- End of line
d$
- End of line
Press v to enter visual mode
- Cut/copy/paste