- Use the three primary modes of vi and vim
- Navigate text and enter Insert mode
- Change, delete, yank and put text
- Undo changes
- Search a document
- Save and exit
- Executing vi runs vim by default
- Applications + Programming –> Vi iMproved
- Provided by vim-X11 package
- Speed: Do more with fewer keystrokes
- Simplicity: No dependence on mouse/GUI
- Availability: Included with most Unix-like OSes
- Difficulty: Steeper learning curve than simpler editor. Key bindings emphasizes speed over intuitiveness
- Command mode (default): Move cursor, cut/paste text, change mode
- Insert mode: Modify text
- Ex Mode: Save, quit, etc
- Open a file
- Modify a file (insert mode)
- Save a file (ex mode)
- vim filename
- If the file exists, the file is opened and the contents are displayed
- If the file does not exist, vi creates it when the edits are saved for the first time
- A append to end of line
- I insert at the begining of the line
- o insert a new line (below)
- O insert a new line (above)
- Creates a command prompt at bottom-left of screen
- :w writes (saves) the file to disk
- :wq wirtes and quits
- :q! quits, even if changes are lost
- Right Arrow moves right one character
- 5, Right Arrow moves five characters
- Affects current line by default
- Use x,y range of % for whole file
Change (replace) | Delete (cut) | Yank (copy) | |
Line | cc | dd | yy |
Letter | cl | dl | yl |
Word | cw | dw | yw |
Sentence ahead | c) | d) | y) |
Sentence behind | c( | d( | y( |
Paragraph above | c{ | d { | y{ |
Paragraph below | c} | d} | y} |
- v starts character-oriented highlighting
- V starts line-oriented highlighting
- Activated with mouse in gvim
- Ctrl+w, s splits the screen horizontally
- Ctrl+w, v splits the screen vertically
- Ctrl+w, Arrow moves between windows
- :set or :set all
- ~/.vimrc or ~/.exrc
- :set number
- :set autoindent
- :set text (vim only)
- :set wrapmargin=15
- :set ignorecase
- :help
- :help topic
- Use :q to exit help
- Use the three primary modes of vi and vim
- Move the cursor and enter Insert mode
- Change, delete, yank and put text
- Undo changes
- Search a document
- Save and exit