Friday, January 22, 2016

UNIX/Linux/Ubuntu system administration DAY 06

Using Vi editor


Vi editor can be in three different modes at a given time.

Command mode: accept commands which are often entered as single letters.

Ex mode: to manipulate files (including savving file and running outside programs. Typing a colon (:) will enter the ex-mode and entering the name of the command. After running the ex-mode, it will automatically return to command mode.

Insert mode: we can enter text in this mode. Presssing Esc key will exit insert mode and returns to command mode. Typing i or a will enter insert mode when in command mode.

Popular Vi commands


When in insert mode

O (letter O) will open a new line immediately below the currnt line.


When in command mode

u will undo any change
o (a lowercase letter O) will open text
~ (tilde) will change case (e.g. a -> A)
/keyword will search forward for text matching keyword.
:q! will end an editing session without saving the modified contents.
:w filename will save the file with the given filename.

l (ell) key and the RIGHT ARROW key will move the cursor forward one character at a time.
h key and the LEFT ARROW key will move the cursor backward one character at a time.

b key will move the cursor backward by a word.
w key will move the cursor forward by a word.

Capitals B and W will jum backward and forward by blank delimited words.

ENTER key will move the cursor to the beginning of the next line.

j and DOWN ARROW key will move the cursor down one line to the character just below the current character.

k and UP ARROW key will move the cursor up one line to the character just above the current character.

x key will delete the current character.

References

[1] Roderick W. Smith, Linux essentials, Sybex, 2012.

No comments:

Post a Comment

Mounting USB drives in Windows Subsystem for Linux

Windows Subsystem for Linux can use (mount): SD card USB drives CD drives (CDFS) Network drives UNC paths Local storage / drives Drives form...