Manual VI
Manual VI
vi --version
vi file_name
:w
:q
:wq
:q!
Search in the file: Type / followed by the phrase you are looking
for. Press N go to next match. You can search backwards using ?
See line numbers: :set nu
Hide line numbers: :set nonu
Spellcheck: :set spell
Turn off spellcheck: :set nospell
Set user spell file: :set spellfile=~/.vim/en.utf-8.add
Browse files and folders using file explorer: :E
Keyboard shortcuts
Key
Description
bindings
G Go to the end of the file
5G Go to specific line of the file (here line 5)
5H Move relative to the top line on the screen
Move relative to the bottom line on the
3L
screen
gg Go to the beginning of file
control + F Scroll forward one page
control + B Scroll backward one page
$ Go to the end of line
0 Go to the beginning of line
dd Delete a whole line
Undo (or type :u; :2u (undo twice)
u
or :U (undo all))
control + R Redo
control + L Redraw / reload
z= Spelling suggestions
zg Add new word to the user dictionary
zug Remove word from the dictionary
. Repeat last command
db Delete one word backwards
dw Delete one word forwards
d$ / D Delete to the end of line
d0 Delete to the beginning of line
vi -d file.txt file_edit.txt
visual mode
Enter Visual mode by pressing v, V or [control] + v for visual
character, line or block modes, respectively. Select text using the
arrow keys on the key board. You can:
Press c it will clear the selected part and enter into insert mode.
Press y to copy (yanked).
You can paste in another location in VIM by pressing p.
Press "+y to copy to system clipboard, you can paste in another
program using your system shortcut like [command] +
v or [control] + v.
Comment multiple lines:
o Enter block visual mode: [control] + v
o Select the lines (first col) using up / down arrow keys
o Enter insert mode: [shift] + i
o Type commenting character e.g., #
o Press [esc].
Un-comment multiple lines:
o Enter block visual mode: [control] + v
o Select the lines (one or multiple columns) using arrow
keys
o Press x followed by [esc].
vimrc
You can customize your vi editor by creating a ~/.vimrc file and saving
your settings there. Like:
syntax on
set tabstop=4
set ruler
colorscheme darkblue
set textwidth=80
set cc=81
set autoindent
set spell
hi SpellBad ctermbg=Yellow
hi SpellBad ctermfg=DarkRed
set spellfile=~/.vim/en.utf-8.add
set hlsearch
hi Search ctermbg=LightBlue
hi Search ctermfg=black
Plugins
Installing vimplug:
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
call plug#begin('~/.vim/plugged')
Plug 'junegunn/goyo.vim'
call plug#end()
You can modify or add your own settings to a plugin. For example, if
you want to call Limelight along with Goyo. Go to
~/.vim/plugged/goyo.vim/autoload/goyo.vim
and add a line Limelight. You may add other settings, say, set
spell etc.