If gvim is run as vim it will behave as vim (i.e. open in the same window)
To to this make a soft link to gvim named vim and then execute it to run gvim as vim
| Description | Commands | Notes |
|---|---|---|
| Begining of Line, Jump to | 0 | The command is the number zero, not the letter 'o' |
| config files show load order (like .vimrc | scriptnames | |
| delete EOL | J | |
| End of Line, Jump to | $ | |
| Jump to EOF | G | |
| Jump to top of file | :1 | 'Goto' line 1 |
| Macro | q{letter to Identify Macro}{do stuff}q | example that deletes 2 lines then moves the cursor down a line:qaddddjqrunning the example 5 times: 5@a |
| Movement (without cursor keys) | h - left | |
| Outline: Collapse all to 1 level | zM | |
| Outline: Collapse entire, one level | zm | |
| Outline: Collapse folder | zc | |
| Outline: Collapse folder to 1 level | zC | |
| Outline: Expand all | zR | |
| Outline: Expand entire, one level | zr | |
| Outline: Folder Expand Completely | zO | |
| Outline: Open folder | zo | ? This may open more than 1 level |
| Redo what was 'undo'-ed (undone) | Control-R | |
| Repeat Last Change | . | So if you did a 4x then moved (or not moved even), and then you type . it will repeat the 4x |
| Replace | :[range]s/from/to/[flags]or long version: :[range]substitute/from/to/[flags] | replace all: :%s/This/That/replace all with confirm: :%s/This/That/creplace current line: :s/This/That/to replace a slash: :s+w/+w/o+c |
| /{pattern}[/] | Search for {pattern} | |
| /{pattern}[/{count}] | Search for the {count}'th occurance of pattern | |
| Search Backwards | %string | |
| Search Next Forward | n | |
| Search Next Reverse | ? | |
| Undo current lines changes | U | |
| Undo last change, can be repeated | u | |
| Window Navigation | control-W upcontrol-W down |
set background=dark
| Variable | Description |
|---|---|
| :set nowrap :set wrap | Turn line wrapping off and on |
| :set background=dark | Changes pallette to accomidate a dark background |
| :set filetype=none | Makes it do file type specific stuff - such as syntax highlighting |
*10.2* Substitution
The ":substitute" command enables you to perform string replacements on a
whole range of lines. The general form of this command is as follows: >
:[range]substitute/from/to/[flags]
This command changes the "from" string to the "to" string in the lines
specified with [range]. For example, you can change "Professor" to "Teacher"
in all lines with the following command: >
:%substitute/Professor/Teacher/
<
Note:
The :substitute command is almost never spelled out completely. Most
of the time, people use the abbreviated version ":s". From here on
the abbreviation will be used.
The "%" before the command specifies the command works on all lines. Without
a range, ":s" only works on the current line. More about ranges in the next
section.
By default, the ":substitute" command changes only the first occurrence on
each line. For example, the preceding command changes the line:
Professor Smith criticized Professor Johnson today. ~
to:
Teacher Smith criticized Professor Johnson today. ~
To change every occurrence on the line, you need to add the g (global) flag.
The command: >
:%s/Professor/Teacher/g
results in (starting with the original line):
Teacher Smith criticized Teacher Johnson today. ~
Other flags include p (print), which causes the ":substitute" command to print
out each line it changes. The c (confirm) flag tells ":substitute" to ask you
for confirmation before it performs each substitution. Enter the following: >
:%s/Professor/Teacher/c
Vim finds the first occurrence of "Professor" and displays the text it is
about to change. You get the following prompt: >
replace with Teacher (y/n/a/q/l/^E/^Y)?
At this point, you must enter one of the following answers:
y Yes; make this change.
n No; skip this match.
a All; make this change and all remaining ones without
further confirmation.
q Quit; don't make any more changes.
l Last; make this change and then quit.
CTRL-E Scroll the text one line up.
CTRL-Y Scroll the text one line down.
The "from" part of the substitute command is actually a pattern. The same
kind as used for the search command. For example, this command only
substitutes "the" when it appears at the start of a line: >
:s/^the/these/
If you are substituting with a "from" or "to" part that includes a slash, you
need to put a backslash before it. A simpler way is to use another character
instead of the slash. A plus, for example: >
:s+one/two+one or two+