/Main_Page

::You must have ninja focus to complete your mission::NinjaFocus::

Vi

Views:

(more linux)

vi is a text editor for linux that works inside text-only bash shells, it's very powerful but can take a little getting used to. be patient and take your time if you're new to it :-)

# vi <filename>

vi has three main modes of operation. The common ones are editing mode and command mode, the other is visual mode.

Commands

  • Esc =exit editing mode and enter command mode
  •  :w =write (save) file
  •  :q =quit file
  •  :q! =quit with out saving
  •  :wq =write (save) file then quit
  • i =insert (goto editing mode)
  • a =append (goto editing mode)
  • r<character> =replace the character under the cursor
  • h =cursor left
  • j =cursor up
  • k =cursor down
  • l =cursor right
  • <cursor keys> =guess
  • dd =delete line
  • o =new line below current (and goto editing mode)
  • O =new line above current (and goto editing mode)
  • v =visual mode
  • p =paste (visual mode)
  • y =yank (copy) (visual mode)
  • d =delete (cut) (visual mode)

visual mode

When in command mode you can press v to enter visual mode. Use the cursor keys to highligh text and then either press y to copy text or d to cut text. if you want to paste the text back, move the cursor in to position then press p. Note that after pressing dd to delete a whole line, you can then paste it somewhere else using the p command.

Main Menu

Personal tools

Toolbox