John

Authored Comments

The vi editor has been a constant throughout my IT career having started out in Unix. It was the one editor I could be sure was available regardless of the Unix or Linux variant I was on. Here are a few useful vi commands I regularly use (and have done for nearly 30 years):-

To Save and exit vi quickly, use:
Shift + ZZ

To delete from the current cursor position to the end of the line:
Shift + D

To delete a specific number of line e.g 5 lines, use:
5dd

To delete a word:
dw

To append at the end of a line:
Shift + A

To copy lines (yank and put) position the cursor on the line to copy and then use:
yyp

To copy 5 lines use:
5yyp

Note, when copying lines, after you have y (yanked) the lines, you can position the cursor to where you need to in the file before you p (put).

To go to the end of the file:
Shift + G

to go to a specific line number e.g line 22:
22 Shift+G

There are a gazilion other features in vi, but you generally tend to find the most useful ones and stick with them. However, from time to time you come accross a scenario in which you require something special and vi always seems to have an answer for it. These days, I like to use vim (Vi Improved) as it adds some nice extras including text highlighting