Here is my favorite list.
1)ab --> abbreviate command
:ab bbc "I am sameer shaik"
Use bbc in the vi editor and it will replace it to"I am Sameer Shaik"
2)line number
:set number
3)autoindent
:set autoindent
4)shiftwdth for autoindent
:set shiftwidth=4
5)Ignore cases on searches
:set ignorecase
6)Switch case
~ (shift+tilda) will change the case.
7)Execute shell command in vi
:!command,
xample, :!pwd to show the present working directory.
or
if you want to run multiple commands then use
:sh <-- this will give you a new shell, once done CTRL D will bring you back to VI
8)save partial content
:start,endw file
9) Editing muliple files.
vi *.txt
:n <-- to go to next file
10)Repeat the previous command.
. (period) to repeat the previous command.
11)Join Lines.
You can give J or count of the number of lines to be joined as in 3J to join 3 lines
The following table lists the file manipulation commands which you can use when you are in vi.
:w write back changes
:wq write and quit
:x write (if necessary) and quit (same as ZZ).
:e name edit file name
:e! reedit, discarding changes
:e + name edit, starting at end
:e +n edit, starting at line n
:e # edit alternate file
:w name write file name
:w! name overwrite file name
:x,yw name write lines x through y to name
:r name read file name into buffer
:r !cmd read output of cmd into buffer
:n edit next file in argument list
:n! edit next file, discarding changes to current
:n args specify new argument list
:ta tag edit file containing tag tag, at tag
String Matching:
$ at end of pattern, matches end of line
. matches any character
\< matches the beginning of a word
\> matches the end of a word
[str] matches any single character in str
[str] matches any single character not in str
[x-y] matches any character between x and y
* matches any number of the preceding pattern
To view the currect options:
:set all
--- Options ---
ambiwidth=single fileformat=unix modelines=5 noshowfulltag ttybuiltin
noautoindent fileignorecase modifiable noshowmatch ttyfast
noautoread fixendofline modified showmode ttyscroll=999
noautowrite formatoptions=tcq more showtabline=1 ttytype=xterm
noautowriteall formatprg= mouse= sidescroll=0 undolevels=1000
background=light fsync mousemodel=extend sidescrolloff=0 undoreload=10000
nobackup nogdefault mousetime=500 nosmartcase updatecount=200
backupcopy=auto helpheight=20 nrformats=bin,hex nosmarttab updatetime=4000
backupext=~ nohidden nonumber softtabstop=0 verbose=0
belloff= history=200 operatorfunc= nosplitbelow verbosefile=
nobinary nohlsearch nopaste nosplitright novisualbell
nobomb noignorecase pastetoggle= startofline warn
buflisted iminsert=0 patchmode= swapfile noweirdinvert
cedit=^F imsearch=0 nopreserveindent swapsync=fsync whichwrap=b,s
cmdheight=1 noincsearch prompt switchbuf= wildchar=<Tab>
cmdwinheight=7 noinfercase noreadonly tabpagemax=10 wildcharm=0
columns=106 noinsertmode regexpengine=0 tabstop=8 wildignore=
nocompatible isprint=@,161-255 norelativenumber tagbsearch nowildignorecase
nocopyindent joinspaces remap tagcase=followic wildmode=full
cpoptions=aABceFs keymodel= report=2 taglength=0 window=104
debug= keywordprg=man scroll=52 tagrelative winheight=1
nodelcombine laststatus=1 scrolljump=1 tags=./tags,tags nowinfixheight
display=truncate nolazyredraw scrolloff=5 tagstack nowinfixwidth
eadirection=both lines=105 nosecure term=xterm winminheight=1
noedcompatible nolist selectmode= termencoding= winminwidth=1
emoji listchars=eol:$ shell=/bin/bash noterse winwidth=20
encoding=utf-8 loadplugins shellcmdflag=-c textauto wrap
endofline magic shellquote= notextmode wrapmargin=0
equalalways matchtime=5 shelltemp textwidth=0 wrapscan
equalprg= maxcombine=2 shellxquote= notildeop write
noerrorbells maxmapdepth=1000 shellxescape= timeout nowriteany
esckeys maxmem=4133370 noshiftround timeoutlen=1000 writebackup
noexpandtab maxmemtot=4133370 shiftwidth=8 ttimeout writedelay=0
noexrc modeline noshortname ttimeoutlen=100
1)ab --> abbreviate command
:ab bbc "I am sameer shaik"
Use bbc in the vi editor and it will replace it to"I am Sameer Shaik"
2)line number
:set number
3)autoindent
:set autoindent
4)shiftwdth for autoindent
:set shiftwidth=4
5)Ignore cases on searches
:set ignorecase
6)Switch case
~ (shift+tilda) will change the case.
7)Execute shell command in vi
:!command,
xample, :!pwd to show the present working directory.
or
if you want to run multiple commands then use
:sh <-- this will give you a new shell, once done CTRL D will bring you back to VI
8)save partial content
:start,endw file
9) Editing muliple files.
vi *.txt
:n <-- to go to next file
10)Repeat the previous command.
. (period) to repeat the previous command.
11)Join Lines.
You can give J or count of the number of lines to be joined as in 3J to join 3 lines
The following table lists the file manipulation commands which you can use when you are in vi.
:w write back changes
:wq write and quit
:x write (if necessary) and quit (same as ZZ).
:e name edit file name
:e! reedit, discarding changes
:e + name edit, starting at end
:e +n edit, starting at line n
:e # edit alternate file
:w name write file name
:w! name overwrite file name
:x,yw name write lines x through y to name
:r name read file name into buffer
:r !cmd read output of cmd into buffer
:n edit next file in argument list
:n! edit next file, discarding changes to current
:n args specify new argument list
:ta tag edit file containing tag tag, at tag
String Matching:
$ at end of pattern, matches end of line
. matches any character
\< matches the beginning of a word
\> matches the end of a word
[str] matches any single character in str
[str] matches any single character not in str
[x-y] matches any character between x and y
* matches any number of the preceding pattern
To view the currect options:
:set all
--- Options ---
ambiwidth=single fileformat=unix modelines=5 noshowfulltag ttybuiltin
noautoindent fileignorecase modifiable noshowmatch ttyfast
noautoread fixendofline modified showmode ttyscroll=999
noautowrite formatoptions=tcq more showtabline=1 ttytype=xterm
noautowriteall formatprg= mouse= sidescroll=0 undolevels=1000
background=light fsync mousemodel=extend sidescrolloff=0 undoreload=10000
nobackup nogdefault mousetime=500 nosmartcase updatecount=200
backupcopy=auto helpheight=20 nrformats=bin,hex nosmarttab updatetime=4000
backupext=~ nohidden nonumber softtabstop=0 verbose=0
belloff= history=200 operatorfunc= nosplitbelow verbosefile=
nobinary nohlsearch nopaste nosplitright novisualbell
nobomb noignorecase pastetoggle= startofline warn
buflisted iminsert=0 patchmode= swapfile noweirdinvert
cedit=^F imsearch=0 nopreserveindent swapsync=fsync whichwrap=b,s
cmdheight=1 noincsearch prompt switchbuf= wildchar=<Tab>
cmdwinheight=7 noinfercase noreadonly tabpagemax=10 wildcharm=0
columns=106 noinsertmode regexpengine=0 tabstop=8 wildignore=
nocompatible isprint=@,161-255 norelativenumber tagbsearch nowildignorecase
nocopyindent joinspaces remap tagcase=followic wildmode=full
cpoptions=aABceFs keymodel= report=2 taglength=0 window=104
debug= keywordprg=man scroll=52 tagrelative winheight=1
nodelcombine laststatus=1 scrolljump=1 tags=./tags,tags nowinfixheight
display=truncate nolazyredraw scrolloff=5 tagstack nowinfixwidth
eadirection=both lines=105 nosecure term=xterm winminheight=1
noedcompatible nolist selectmode= termencoding= winminwidth=1
emoji listchars=eol:$ shell=/bin/bash noterse winwidth=20
encoding=utf-8 loadplugins shellcmdflag=-c textauto wrap
endofline magic shellquote= notextmode wrapmargin=0
equalalways matchtime=5 shelltemp textwidth=0 wrapscan
equalprg= maxcombine=2 shellxquote= notildeop write
noerrorbells maxmapdepth=1000 shellxescape= timeout nowriteany
esckeys maxmem=4133370 noshiftround timeoutlen=1000 writebackup
noexpandtab maxmemtot=4133370 shiftwidth=8 ttimeout writedelay=0
noexrc modeline noshortname ttimeoutlen=100