http://goo.gl/EmKxy0

Home > UNIX > Vi Editor – Part 1

Vi Editor – Part 1

Basic Vi Editor commands
————————
Problem 1
———
How to do the undo in Vi editor?

Solution 1
———-
Go to command mode and press “u” to undo the last action.

Problem 2
———
How to convert lines into comments?

Solution 2
———
Use “I” and “A”
“I” inserts at the beginning of line.
“A” appends at the end of line.
So press “I” and type /* then [Escape] and then press “A” and type */ then [Escape]. Due to this each line can be converted to comment.

Problem 3
———
How to insert lines above and below the current line without placing the cursor at the start and end of line?

Solution 3
———-
Use “o” and “O”
open a file in command mode and press “o” which inserts a new line below the current line.
Open a file in command mode and press “O” which inserts a new line above the current line.

Problem 4
———
What is the difference between s,S,r,R in command mode?

Solution 4
———
r –> Replaces a single character with one character.
R –> Replaces all text on the right of the cursor position.
s –> Replaces a single character with many.
S –> Replaces the entire line irrespective of cursor position.

Problem 5
———
How to save and quit in one character?

Solution 5
———
Use “:x” in command mode.

Check the Sybase Wiki @ sybasewiki.com
Categories: UNIX Tags:
  1. No comments yet.
  1. No trackbacks yet.