1. Skip to Menu
  2. Skip to Content
  3. Skip to Footer

DIAS is a portal that can help you get your work done

Αυτή η υπηρεσία μπορεί να σας βοηθήσει να γίνετε πιο αποτελεσματικοί στην τάξη και στο μάθημα σας γενικότερα...

Basic commands for the Linux vi Editor

The Linux VI Editor is a text based editor used Linux, useful for editing configuration files or creating plain text documents.

vi is started by simply entering "vi" (it is case sensitive) at the linux prompt, and once started is exited using ESC:q! to abandon changes or SHIFT+ZZ (case sensitve) to save changes. If you want to edit (or create) a specific file use the command "vi /path_to_file/name_of_file". "path_to_file" must already exist as vi will not make any required directories.

Command Description
i insert mode, (ESC to exit insert mode) allows text to be entered on the screen
a Append to right mode
/word Move to the occurrence of "word"
n Locate the next occurrence
w Advance to the next word
e Advance to the next end of a word
b Move to the previous word
3b Move backward 3 words
yy Copy line (then move cursor and use p to paste after current cursor line)
dd delete line
3dd delete 3 lines
D Delete remainder of a line
dw Delete word
x Delete character
o Open space for new line below the cursor line
O Open a line above the cursor
CTRL-w Move back a word in append mode
u Undo last
U Undo all changes to current line
. In command mode, repeat the last text changing the command on the current line
:w newfilename save the file to newfilename from the command mode
:wq save and quit
:q! quit without saving
r replace then typa a character ot be replaced with r then return to break up a line
J join 2 lines
s substitute (sentence) typed text over a character, ESC when done
cw change word
c change part of a line from the cursor to the end of the line
cc substitute new text for aline, ESC when done
h move the cursor back one space
H move the cursor to the highest line on the screen
L move the cursor to the lowest line on the screen
M position the cursor at the midpoint on the screen
G last line in the file
0 (zero) Move the cursor to the beginning of the line it is on
view filename Open a file for viewing only
set number Turn on line numbers
set nonumber Turn off line numbers
autoindent (ai ctrl-d to move to the left
showmatch match brackets and parenthesis
wrapmargine(wm) when line is wrapped (80-value)
:2 copy 4 Place a copy of line 2 after line 4.
:1,4 copy 7 (lines 1-4)
:n Access the next file for editing