After a successful installation of SAS Enterprise BI Server on my Sun Servers, a certain amount of time is spent modifying configuration files and backup scripts, as well as browsing log files. I use the vi editor to accomplish the editing. I used used vi a lot back when all of my GIS work was performed in the UNIX environment, but once the Intel hardware matured and the GIS tools because available on Windows, I thought I would be able to forget all about the UNIX command line. Wrong. I’m back there again, but now I’m armed with a cheat sheet:
Working with files
|
Vim Command |
Action |
|
vi filename |
Opens a file with the Vim editor. |
|
:w filename |
Save changes to a file. If you don’t specify a file name, Vim saves as the file name you were editing. For saving the file under a different name, specify the file name. |
|
:q |
Quit Vim. If you have unsaved changes, Vim refuses to exit. |
|
:q! |
Exit Vim without saving changes. |
|
:wq |
Write the file and exit. |
Moving around in the file
|
Vim command |
Action |
|
j or Up Arrow |
Move the cursor up one line. |
|
k or Down Arrow |
Down one line. |
|
h or Left Arrow |
Left one character. |
|
l or Right Arrow |
Right one character. |
|
0 |
To the beginning of a line. |
|
$ |
To the end of a line. |
|
:n |
Jump to line number n. |
Inserting and overwriting text
|
Vim command |
Action |
|
i |
Insert before cursor. |
|
o |
Open a new line below and insert. |
|
O |
Open a new line above and insert. |
|
C |
Change the rest of the current line. |
|
r |
Overwrite one character. After overwriting the single character, go back to command mode. |
|
R |
Enter insert mode but replace characters rather than inserting. |
|
The ESC key |
Exit insert/overwrite mode and go back to command mode. |
Deleting text
|
Vim command |
Action |
|
x |
Delete characters under the cursor. |
|
X |
Delete characters before the cursor. |
|
dd or :d |
Delete the current line. |
Undo and redo
|
Vim command |
Action |
|
u |
Undo the last action. |
|
U |
Undo all the latest changes that were made to the current line. |
|
Ctrl + r |
Redo. |
There are obviously many more Vim commands out there. Typically if I find myself in a situation where extensive modifications need to be made with a text editor, I will use Crimson Editor on Windows.
The list of commands above are a subset of The Vim commands cheat sheet – 1.2.