This document summarizes common commands in the VI text editor for navigating and editing text. It outlines commands for switching between modes, moving the cursor, deleting/changing text, searching/replacing text, and saving/quitting. Helpful commands are also included for syntax highlighting, line numbering, auto-indentation, and setting indentation width.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as ODT, PDF, TXT or read online from Scribd
This document summarizes common commands in the VI text editor for navigating and editing text. It outlines commands for switching between modes, moving the cursor, deleting/changing text, searching/replacing text, and saving/quitting. Helpful commands are also included for syntax highlighting, line numbering, auto-indentation, and setting indentation width.
This document summarizes common commands in the VI text editor for navigating and editing text. It outlines commands for switching between modes, moving the cursor, deleting/changing text, searching/replacing text, and saving/quitting. Helpful commands are also included for syntax highlighting, line numbering, auto-indentation, and setting indentation width.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as ODT, PDF, TXT or read online from Scribd
This document summarizes common commands in the VI text editor for navigating and editing text. It outlines commands for switching between modes, moving the cursor, deleting/changing text, searching/replacing text, and saving/quitting. Helpful commands are also included for syntax highlighting, line numbering, auto-indentation, and setting indentation width.
Copyright:
Attribution Non-Commercial (BY-NC)
Available Formats
Download as ODT, PDF, TXT or read online from Scribd
Download as odt, pdf, or txt
You are on page 1of 2
VI Editor Commands
Switch to Text or Insert mode:
Open line O above cursor Insert text at Insert text at Insert text Append text at I i a A beginning of line cursor after cursor line end Open line o below cursor Switch to Command mode: Switch to <ESC command mode > Cursor Movement (command mode): Scroll Backward 1 <ctrl>b screen Scroll Up 1/2 screen <ctrl>u Go to beginning Go to end of 0 Go to line n nG $ of line line Scroll Down 1/2 Go to line <ctrl>d :## screen number ## Scroll Forward 1 <ctrl>f screen Go to last line G Scroll by sentence () f/b w Move left, down, Scroll by word f/b hjkl Left 6 chars 6h b up, right Directional Arrow Go to line #6 6G Movement Keys Deleting text (command mode): Change cw Replace one character r word Delete entire line (to Delete word dw Delete text at cursor x dd buffer) Delete current to end of Delete 5 lines (to D 5dd line buffer) Delete lines 5-10 :5,10d Editing (command mode): Copy lines 1- Copy n Copy line yy nyy 2/paste after :1,2t 3 lines 3 Paste above current P line Move lines Paste below current :4,5m p 4-5/paste line 6 after 6 Join previous J line Search Find next Search backward for / ?string forward for string n string string string occurrence % (entire file) s (search and : replace) /old text %s/oldstring Ignore case :set ic with new/ c /newstring/c during search (confirm) g (global - g all) Undo Undo all Repeat last . previous u changes to U command command line Save and Quit (command mode): Save changes to Save changes and Save file to new :w :wq :w file buffer quit vi file Save lines to :10,15w Quit without saving :q! new file file :syntax on Turn on syntax highlighting :syntax off Turn off syntax highlighting :set number Turn on Line numbering (shorthand :set nu) :set nonumber Turn off Line numbering (shorthand :set nonu) :set ignorecase Ignore case sensitivity when searching :set noignorecase Restore case sensitivity (default)
:set autoindent Turn on Auto-indentation
Use the command >> to indent and the << command to outdent :set shiftwidth=4 Set indentation to four spaces :set noautoindent Turn off Auto-indentation “vi was written for a world that doesn't exist anymore - unless you decide to get a satellite phone and use it to connect to the Net at 2400 baud” - Bill Joy