:! command
This will run a.out:
:! a.out
This will compile the program z.c:
:! cc z.c
You can use % as a shorthand reference to the current file.
This will compile the file you are editing:
:! cc %
You can repeat the last shell command you entered (good for repeated compiles):
:!!
You can compile the current file and place error messages in a file list
:! cc % 2> err_lst
You can move back and forth between two files easily. If you are in
file a , and want to edit file b enter :e b .
Now you want to go back to file a enter :e # . This is useful
if you place the compilation errors on the file err_lst (see
above) and want to go back and forth between your file and the
error file.
:set showmatch
and type the following
while ( blah blah blah ) {
do this loop }
When you type the closing parenthesis or closing brace you
should see the cursor jump to the opening parenthesis or brace.
Next place the cursor at one of the parens or braces, and
press the % key. The cursor should jump to the matching
paren or brace. (also works for square brackets).
:set shiftwidth=4
Now at any line enter >> ; the line should
be shifted 4 spaces; enter 3<< and the 3 lines
at the cursor should be shifted 4 spaces. This is useful
for increasing the indentation of a block of code.
:set tabstop=4
and pressing the tab key in insert mode will move the
code over 4 spaces
pr -t -e4 file.c > file.txt
:set showmatch
:set shiftwidth=4
:set tabstop=4
Everytime vi starts up, it looks for this file
and executes all commands in it
while (a > 0 ) {
do thing
}
.....
more stuff
.....
and you wanted to copy the while loop after the more stuff.
There are several ways to do the; the more general way may
1,$s/.\(..\)$/::\1