From wikistone
Jump to: navigation, search

multiple files

vi file1 file2 ...

  • :n : move to next file
  • :N : move to prev file
  • :buffers : list open files
  • :buffer n : move to n buffer
  • :e file : open/edit file
  • :r file : inserts file before the cursor into current file


substitution

:%s/[search]/[replace]/[args]
  •  % : range of lines, % = 1,$ ; $ = last
  • s : substitution command
  • args:
    • g : global, ie all occurrences on the line; omition means only 1st occurrence
    • c : confirm
      • y : yes
      • n : no
      • a : yes to this and all subsequent
      • l : last sub, ie yes to this then quit
      • q : quit subing
      • Esc : quit subing
      • ctrl-e : scroll down for context
      • ctrl-y : scroll up for context