SlideShare a Scribd company logo
1 of 2
Download to read offline
VI “Cheat” Sheet
                                                                                               ACNS Bulletin ED–03
                                                                                                   February 1995

                                  vi Editor “Cheat Sheet”
Invoking vi:                         vi filename
Format of vi commands:               [count][command]            (count repeats the effect of the command)

Command mode versus input mode                                   File management commands

Vi starts in command mode. The positioning commands               :w name         Write edit buffer to file name
operate only while vi is in command mode. You switch vi           :wq             Write to file and quit
to input mode by entering any one of several vi input com-        :q!             Quit without saving changes
mands. (See next section.) Once in input mode, any charac-        ZZ              Same as :wq
ter you type is taken to be text and is added to the file. You    :sh             Execute shell commands (<ctrl>d)
cannot execute any commands until you exit input mode.
To exit input mode, press the escape (Esc) key.
                                                                 Window motions
Input commands (end with Esc)                                     <ctrl>d         Scroll down (half a screen)
                                                                  <ctrl>u         Scroll up (half a screen)
 a                    Append after cursor
                                                                  <ctrl>f         Page forward
 i                    Insert before cursor
                                                                  <ctrl>b         Page backward
 o                    Open line below
                                                                  /string         Search forward
 O                    Open line above
                                                                  ?string         Search backward
 :r file              Insert file after current line
                                                                  <ctrl>l         Redraw screen
Any of these commands leaves vi in input mode until you           <ctrl>g         Display current line number and
press Esc. Pressing the RETURN key will not take you out                          file information
of input mode.
                                                                  n               Repeat search
                                                                  N               Repeat search reverse
Change commands (Input mode)                                      G               Go to last line
                                                                  nG              Go to line n
 cw                   Change word (Esc)
                                                                  :n              Go to line n
 cc                   Change line (Esc) - blanks line
                                                                  z<CR>           Reposition window: cursor at top
 c$                   Change to end of line
                                                                  z.              Reposition window: cursor in middle
 rc                   Replace character with c
                                                                  z-              Reposition window: cursor at bottom
 R                    Replace (Esc) - typeover
 s                    Substitute (Esc) - 1 char with string
 S                    Substitute (Esc) - Rest of line with       Cursor motions
                      text
                                                                  H               Upper left corner (home)
 .                    Repeat last change
                                                                  M               Middle line

Changes during insert mode
                                                                  L               Lower left corner
                                                                  h               Back a character
 <ctrl>h              Back one character                          j               Down a line
 <ctrl>w              Back one word                               k               Up a line
 <ctrl>u              Back to beginning of insert                 ^               Beginning of line
                                                                  $               End of line
                                                                  l               Forward a character
                                                                  w               One word forward
                                                                  b               Back one word
                                                                  fc              Find c
                                                                  ;               Repeat find (find next c)
Deletion commands                                         Move text from file old to file new
dd or ndd           Delete n lines to general buffer       vi old
dw                  Delete word to general buffer          “a10yy               yank 10 lines to buffer a
dnw                 Delete n words                         :w                   write work buffer
d)                  Delete to end of sentence              :e new               edit new file
db                  Delete previous word                   “ap                  put text from a after cursor
D                   Delete to end of line                  :30,60w new          Write lines 30 to 60 in file new
x                   Delete character
                                                          Regular expressions (search strings)
Recovering deletions
                                                           ^                    Matches beginning of line
p                   Put general buffer after cursor        $                    Matches end of line
P                   Put general buffer before cursor       .                    Matches any single character
                                                           *                    Matches any previous character
Undo commands                                              .*                   Matches any character

u                   Undo last change
                                                          Search and replace commands
U                   Undo all changes on line


Rearrangement commands
                                                          Syntax:
                                                                :[address]s/old_text/new_text/
yy or Y             Yank (copy) line to general buffer
“z6yy               Yank 6 lines to buffer z              Address components:
yw                  Yank word to general buffer            .               Current line
“a9dd               Delete 9 lines to buffer a             n               Line number n
“A9dd               Delete 9 lines; Append to buffer a     .+m             Current line plus m lines
“ap                 Put text from buffer a after cursor    $               Last line
p                   Put general buffer after cursor        /string/        A line that contains "string"
P                   Put general buffer before cursor       %               Entire file
J                   Join lines                             [addr1],[addr2] Specifies a range

                                                          Examples:
Parameters
                                                            The following example replaces only the first occur-
:set list           Show invisible characters               rence of Banana with Kumquat in each of 11 lines
:set nolist         Don’t show invisible characters         starting with the current line (.) and continuing for the
                                                            10 that follow (.+10).
:set number         Show line numbers
:set nonumber       Don’t show line numbers                     :.,.+10s/Banana/Kumquat

:set autoindent  Indent after carriage return               The following example replaces every occurrence
:set noautoindentTurn off autoindent                        (caused by the g at the end of the command) of
:set showmatch   Show matching sets of                      apple with pear.
                 parentheses as they are typed
:set noshowmatch Turn off showmatch                             :%s/apple/pear/g

:set showmode       Display mode on last line of screen     The following example removes the last character from
:set noshowmode     Turn off showmode                       every line in the file. Use it if every line in the file ends
:set all            Show values of all possible             with ^M as the result of a file transfer. Execute it
                    parameters                              when the cursor is on the first line of the file.
                                                                :%s/.$//

More Related Content

Viewers also liked

REA actividad 2o modulo
REA actividad 2o moduloREA actividad 2o modulo
REA actividad 2o moduloRaul Rodriguez
 
Hakumana (testimonio hna evelyn
Hakumana (testimonio hna evelynHakumana (testimonio hna evelyn
Hakumana (testimonio hna evelynPili Jimenez
 
Comunicacion oral y escrita
Comunicacion oral y escritaComunicacion oral y escrita
Comunicacion oral y escritalewisrico97
 
Yanira 1211306357793315-8
Yanira 1211306357793315-8Yanira 1211306357793315-8
Yanira 1211306357793315-8Anthony1396
 
脂肪肝的預備 1
脂肪肝的預備 1脂肪肝的預備 1
脂肪肝的預備 1ccit mate35
 
Si yo cambiara
Si yo cambiaraSi yo cambiara
Si yo cambiaraandream07
 
Local news and natuional
Local news and natuionalLocal news and natuional
Local news and natuionalperryrowe
 
Sustentación proyecto 3 fernando l. fotonovela
Sustentación proyecto 3 fernando l. fotonovelaSustentación proyecto 3 fernando l. fotonovela
Sustentación proyecto 3 fernando l. fotonovelaFernando León Soto
 
Help my image is too small
Help my image is too smallHelp my image is too small
Help my image is too smallsolve99problems
 
Articulo antimicrobianos en_el_calostro_bovino(6)
Articulo antimicrobianos en_el_calostro_bovino(6)Articulo antimicrobianos en_el_calostro_bovino(6)
Articulo antimicrobianos en_el_calostro_bovino(6)Arturo Athié Athié
 
《人人都是产品经理》电子书
《人人都是产品经理》电子书《人人都是产品经理》电子书
《人人都是产品经理》电子书evcn
 

Viewers also liked (20)

REA actividad 2o modulo
REA actividad 2o moduloREA actividad 2o modulo
REA actividad 2o modulo
 
2013 Social Justice PP
2013 Social Justice PP2013 Social Justice PP
2013 Social Justice PP
 
Hakumana (testimonio hna evelyn
Hakumana (testimonio hna evelynHakumana (testimonio hna evelyn
Hakumana (testimonio hna evelyn
 
Erika stefani
Erika stefaniErika stefani
Erika stefani
 
Comunicacion oral y escrita
Comunicacion oral y escritaComunicacion oral y escrita
Comunicacion oral y escrita
 
Yanira 1211306357793315-8
Yanira 1211306357793315-8Yanira 1211306357793315-8
Yanira 1211306357793315-8
 
CONTROL DE TV
CONTROL DE TV CONTROL DE TV
CONTROL DE TV
 
Tolin
TolinTolin
Tolin
 
Horario de especializacion aula 1
Horario de especializacion aula 1Horario de especializacion aula 1
Horario de especializacion aula 1
 
Denial
DenialDenial
Denial
 
脂肪肝的預備 1
脂肪肝的預備 1脂肪肝的預備 1
脂肪肝的預備 1
 
Si yo cambiara
Si yo cambiaraSi yo cambiara
Si yo cambiara
 
Local news and natuional
Local news and natuionalLocal news and natuional
Local news and natuional
 
Sustentación proyecto 3 fernando l. fotonovela
Sustentación proyecto 3 fernando l. fotonovelaSustentación proyecto 3 fernando l. fotonovela
Sustentación proyecto 3 fernando l. fotonovela
 
Help my image is too small
Help my image is too smallHelp my image is too small
Help my image is too small
 
Volcan
VolcanVolcan
Volcan
 
Articulo antimicrobianos en_el_calostro_bovino(6)
Articulo antimicrobianos en_el_calostro_bovino(6)Articulo antimicrobianos en_el_calostro_bovino(6)
Articulo antimicrobianos en_el_calostro_bovino(6)
 
Espiíritus
Espiíritus Espiíritus
Espiíritus
 
《人人都是产品经理》电子书
《人人都是产品经理》电子书《人人都是产品经理》电子书
《人人都是产品经理》电子书
 
Knowing the characters
Knowing the charactersKnowing the characters
Knowing the characters
 

Similar to API TEST

Similar to API TEST (20)

Vi Cheat Sheet v 1 00
Vi Cheat Sheet v 1 00Vi Cheat Sheet v 1 00
Vi Cheat Sheet v 1 00
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
 
Vi cheat sheet
Vi cheat sheetVi cheat sheet
Vi cheat sheet
 
Vi Editor Cheat Sheet
Vi Editor Cheat SheetVi Editor Cheat Sheet
Vi Editor Cheat Sheet
 
Using vi editor
Using vi editorUsing vi editor
Using vi editor
 
Using VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit KumarUsing VI Editor in Red Hat by Rohit Kumar
Using VI Editor in Red Hat by Rohit Kumar
 
vim-cheatsheet.pdf
vim-cheatsheet.pdfvim-cheatsheet.pdf
vim-cheatsheet.pdf
 
Vi editor commands
Vi editor commandsVi editor commands
Vi editor commands
 
Vi CheatSheet
Vi CheatSheetVi CheatSheet
Vi CheatSheet
 
Vi reference
Vi referenceVi reference
Vi reference
 
Vi reference
Vi referenceVi reference
Vi reference
 
Vim Cheat Sheet.pdf
Vim Cheat Sheet.pdfVim Cheat Sheet.pdf
Vim Cheat Sheet.pdf
 
Vim 1
Vim 1Vim 1
Vim 1
 
UNIX - Class2 - vi Editor
UNIX - Class2 - vi EditorUNIX - Class2 - vi Editor
UNIX - Class2 - vi Editor
 
Vi editor
Vi editorVi editor
Vi editor
 
1359 Vi Editor
1359 Vi Editor1359 Vi Editor
1359 Vi Editor
 
GNU Emacs Reference Card.pdf
GNU Emacs Reference Card.pdfGNU Emacs Reference Card.pdf
GNU Emacs Reference Card.pdf
 
015-Editing-Files-With-Vi.pdf
015-Editing-Files-With-Vi.pdf015-Editing-Files-With-Vi.pdf
015-Editing-Files-With-Vi.pdf
 
Vim Cards - Keynote Format
Vim Cards - Keynote FormatVim Cards - Keynote Format
Vim Cards - Keynote Format
 
VI Editors
VI EditorsVI Editors
VI Editors
 

API TEST

  • 1. VI “Cheat” Sheet ACNS Bulletin ED–03 February 1995 vi Editor “Cheat Sheet” Invoking vi: vi filename Format of vi commands: [count][command] (count repeats the effect of the command) Command mode versus input mode File management commands Vi starts in command mode. The positioning commands :w name Write edit buffer to file name operate only while vi is in command mode. You switch vi :wq Write to file and quit to input mode by entering any one of several vi input com- :q! Quit without saving changes mands. (See next section.) Once in input mode, any charac- ZZ Same as :wq ter you type is taken to be text and is added to the file. You :sh Execute shell commands (<ctrl>d) cannot execute any commands until you exit input mode. To exit input mode, press the escape (Esc) key. Window motions Input commands (end with Esc) <ctrl>d Scroll down (half a screen) <ctrl>u Scroll up (half a screen) a Append after cursor <ctrl>f Page forward i Insert before cursor <ctrl>b Page backward o Open line below /string Search forward O Open line above ?string Search backward :r file Insert file after current line <ctrl>l Redraw screen Any of these commands leaves vi in input mode until you <ctrl>g Display current line number and press Esc. Pressing the RETURN key will not take you out file information of input mode. n Repeat search N Repeat search reverse Change commands (Input mode) G Go to last line nG Go to line n cw Change word (Esc) :n Go to line n cc Change line (Esc) - blanks line z<CR> Reposition window: cursor at top c$ Change to end of line z. Reposition window: cursor in middle rc Replace character with c z- Reposition window: cursor at bottom R Replace (Esc) - typeover s Substitute (Esc) - 1 char with string S Substitute (Esc) - Rest of line with Cursor motions text H Upper left corner (home) . Repeat last change M Middle line Changes during insert mode L Lower left corner h Back a character <ctrl>h Back one character j Down a line <ctrl>w Back one word k Up a line <ctrl>u Back to beginning of insert ^ Beginning of line $ End of line l Forward a character w One word forward b Back one word fc Find c ; Repeat find (find next c)
  • 2. Deletion commands Move text from file old to file new dd or ndd Delete n lines to general buffer vi old dw Delete word to general buffer “a10yy yank 10 lines to buffer a dnw Delete n words :w write work buffer d) Delete to end of sentence :e new edit new file db Delete previous word “ap put text from a after cursor D Delete to end of line :30,60w new Write lines 30 to 60 in file new x Delete character Regular expressions (search strings) Recovering deletions ^ Matches beginning of line p Put general buffer after cursor $ Matches end of line P Put general buffer before cursor . Matches any single character * Matches any previous character Undo commands .* Matches any character u Undo last change Search and replace commands U Undo all changes on line Rearrangement commands Syntax: :[address]s/old_text/new_text/ yy or Y Yank (copy) line to general buffer “z6yy Yank 6 lines to buffer z Address components: yw Yank word to general buffer . Current line “a9dd Delete 9 lines to buffer a n Line number n “A9dd Delete 9 lines; Append to buffer a .+m Current line plus m lines “ap Put text from buffer a after cursor $ Last line p Put general buffer after cursor /string/ A line that contains "string" P Put general buffer before cursor % Entire file J Join lines [addr1],[addr2] Specifies a range Examples: Parameters The following example replaces only the first occur- :set list Show invisible characters rence of Banana with Kumquat in each of 11 lines :set nolist Don’t show invisible characters starting with the current line (.) and continuing for the 10 that follow (.+10). :set number Show line numbers :set nonumber Don’t show line numbers :.,.+10s/Banana/Kumquat :set autoindent Indent after carriage return The following example replaces every occurrence :set noautoindentTurn off autoindent (caused by the g at the end of the command) of :set showmatch Show matching sets of apple with pear. parentheses as they are typed :set noshowmatch Turn off showmatch :%s/apple/pear/g :set showmode Display mode on last line of screen The following example removes the last character from :set noshowmode Turn off showmode every line in the file. Use it if every line in the file ends :set all Show values of all possible with ^M as the result of a file transfer. Execute it parameters when the cursor is on the first line of the file. :%s/.$//