vi editing  «Prev  Next»
Lesson 1

Advanced editing with vi

This module covers advanced topics using the vi editor. After reviewing basic concepts, you will learn how to search for text and by customizing vi. You can customize vi during an editing session and the changes will affect only that session. You also can store custom settings in vi's configuration file so that they take effect every time you run vi.
By the end of this module, you will be able to:
  1. Identify basic concepts and vi commands
  2. Search for text in vi
  3. Create text abbreviations with the :ab command
  4. Create keyboard macros with the :map command
  5. Configure vi using the :set command
  6. Use the .exrc file to store vi settings
  7. Edit multiple files
  8. Paste text between files

In the next lesson, you will review key concepts of vi.


  #  (where # is a number) following command n times...  
  :  go to ex-mode 
  )  next sentence 
  (  previous sentence 
  }  next paragraph 
  {  previous paragraph 
 ]]  next section 
 [[  previous section
  0  beginning of line 
  $  end of line 
  ^  first non-whitespace character
  +  first character of next line 
  -  first character of previous line 
(spacebar) next character 
(return) next line 

Linux OS Concepts
The following commands are valid in the `vi` editor. Here’s a brief overview of each:
  1. `/` and `?`: Search forward and backward, respectively.
  2. `%`: Find the matching parenthesis, brace, or bracket.
  3. `,` and `;`: Reverse and repeat the last `f`, `F`, `t`, or `T` command.
  4. `.`: Repeat the last command.
  5. `` ` `` and `'`: Navigate to marks or locations.
  6. `~`: Toggle case of the current character.
  7. `"`: Store in a register.
  8. `!!` and `!`: Execute shell commands.
  9. `>>`, `<<`, `>%`, `<%`: Shift text right or left.
These commands provide powerful text manipulation and navigation in `vi`.
 
  a  append after the current location 
  A  append at the end of the line
 ^a  unused
  b  beginning of previous word 
  B  beginning of previous word, ignore punctuation 
 ^b  scroll back one screen
  c  change until...  
  C  change to end of line 
 ^c  ends insert mode, unused in command mode
  d  delete until...  
  D  delete to end of line 
 ^d  scroll down half a window, moves to previous shiftwidth in insert mode
  e  end of word 
  E  end of word, ignore punctuation 
 ^e  scroll screen down one line
  f  find...  
  F  find backward...  
 ^f  scroll forward one screen
  g  unused 
  G  ...Goto  [defaults to end of file] 
 ^g  show status line
  h  left 
  H  first line on screen 
 ^h  backspace in insert mode, left in command mode
  i  insert before current location 
  I  insert before first non-whitespace character on line 
 ^i  tab in insert, unused in command
  j  down 
  J  join next line with current line 
 ^j  down in command, create newline in insert
  k  up 
  K  unused 
 ^k  unused

l  right 
  L  last line on screen 
 ^l  redraw screen
  m  mark position into register 
  M  middle of screen 
 ^m  carriage return
  n  repeat last search 
  N  repeat last search, reverse direction 
 ^n down in command
  o  open line below current 
  O  open line above current 
 ^o  unused
  p  put below current line 
  P  put above current line 
 ^p  up in command
  q  unused 
  Q  quit and run ex 
 ^q  unused
  r  replace current character 
  R  replace characters until insert mode is left 
 ^r  redraw screen in command mode
  s  substitute 
  S  substitute entire line 
 ^s  unused
  t  to...  
  T  backward to...  
 ^t  moves to next shiftwidth.
  u  undo last change 
  U  undo changes to current line 
 ^u  scroll up half a window
  v  unused 
  V  unused 
 ^v  unused
  w  beginning of next word 
  W  beginning of next word, ignore punctuation 
 ^w  unused in command, in insert move back to beginning of previous
       word
  x  delete current character 
  X  delete previous character 
 ^x  unused
  y  yank...  
  Y  yank current line 
 ^y  scroll screen up one line
  z  reposition screen around line (Return to top of screen, . to 
       middle, - to bottom) 
 ZZ  write and quit 
 ^z  unused

SEMrush Software 1 SEMrush Banner 1