VI Kommandos
Das meiste hier ist geklaut von diversen Seiten (siehe Quellen ganz unten im Dokument).
Und natürlich ist auch diese Seite selber - zumindest zum grösten Teil - auch in VI(M) geschrieben... einen kleinen Emacs-Rückfall hatte ich aber doch.
Allgemein
Es gibt drei Modi:
- Command Mode - der normale und initiale Modus
- Input Mode - da wo man Text eingeben kann
- Line Mode - bei gewissen Befehlen kann man in der untersten Zeile Zeug eingeben
Kommandos
| Command | Action |
| :w | Write - File speichern |
| :q | Quit - geht nur wenn gespeichert |
| :w! | force write - auch ohne gesetzes w (aber man muss natürlich der Fileowner sein) |
| :q! | force quite - ohne zu speichern |
| :e! | re-edit the file (neu laden) |
| :r | read File - es wird nach aktueller Position in die aktuelle Datei eingefügt. |
| :!<cmd> | ein Unix Kommando ausführen (CTRL-D um zurückzukommen) |
Allgemeines
| Command | Action |
| ^G | tell what is going on |
| . | repeats the changing command |
| '' | zur letzten Position zurückspringen |
| U | undoes the changes you made to the current line |
| u | undoes the last change |
| <Zahl> | wiederholt das nächste Kommando Zahl mal |
Moving Around
| Command | Action |
| Scrollen |
| ^D | scrolls down in the file |
| ^U | scrolls up in the file |
| ^Y | exposes another line at the top |
| ^E | exposes another line at the bottom |
| Cursor absolut bewegen |
| H | home screen line |
| M | middle screen line |
| L | last screen line |
| G | go to specified line, last default |
| 0 | Zeilenanfang |
| $ | Zeilenende |
| Suchen |
| / | scan for a following string forwards |
| ? | scan backwards |
| n, N | scan for next instance of / or ? pattern, N kehrt die Suchrichtung um |
| Cursor relativ bewegen |
| b | back a word |
| B | back a word, ignoring punctuation |
| w | word after this word |
| W | forward a word, ignoring punctuation |
| e | end of current word |
| % | gehe zu passender Klammer ( '(', '[' oder '{' ) |
| 1 |
<tr><td>:e!</td><td>re-edit the f%le (neu laden)</td></tr>
|
| |
0_______________________________B_b__Cw_e_W____%_________$
|
Simple Edit
| Command | Action |
| Während der Eingabe |
| ^W | erase a word during an insert |
| erase | your erase (usually ^H or #), erases a character during an insert |
| kill | your kill (usually @, ^X, or ^U), kills the insert on this line |
| ^n, ^p | Keyword completion |
| In den Inputmodus wechseln |
| a | Append, nach Cursor einfügen |
| A | Einfügen am Zeilenende |
| i | Insert, vor Cursor einfügen |
| I | Einfügen am Zeilenanfang |
| o, O | Opens new line, nach und vor der aktuellen Zeile |
| Objektbezogene Operationen |
| c | changes the object you specify to the following text |
| C | Ersetze den Rest der Zeile |
| d | deletes the object you specify |
| D | Löschen bis zum Zeilenende |
| y | copy the object you specify |
| dw | delete word |
| yb | copy word (backwards) |
| dSPACE | delete a single character |
| cw | change a word |
| dd | delete a line |
| 4dd | delete 4 lines |
| cc | change a whole line |
| einzelne Charakter Operationen |
| x | delete a single character |
| rX | ersetze das aktuelle Zeichen durch X |
| ~ | change case of charagter under cursor |
| p, P | paste the buffer after / before the current line |
SED / Regex
Allgemein können die Kommandos mit
:x,y gebilded werden, wobei das Kommando dann auf Zeile
x bis
y angewendet werden.
Werden keine Zeilen angegeben, wird
:.,. - also die aktuelle Zeile - angenommen.
| Command | Action |
| Beispiel |
| :.,$s/hi/lo/g | Ein SED Kommando, von Zeile . bis Zeile $ |
| Zeilenangabe |
| . | aktuelle Zeile |
| $ | Dateiende |
| +10 | aktuelle Zeilenzahl + 10 |
| % | ganze Datei (dann ohne ",") |
| /abc/,/ct/ | von der Zeile mit dem ersten abc bis zur nächsten Zeile mit ct drin. |
| Kommandos |
| s | search and replace |
| d | ein d statt ein s und schon werden Zeilen gelöscht |
| Argumente |
| /g | alle ersetzen (nicht nur eines) pro Zeile |
| /i | Case ignorieren |
| /I | Case nicht ignorieren |
| /c | Bestätigung für jedes Ersetzen |
/Write/
/force/
. -->
+2
$
|
1
2
3
4
5
6
7
8
9
10
|
<h3 class="pages">Kommandos</h3>
<table class="prettytable">
<tr><th>Command</th><th>Action</th></tr>
<tr><td>:w</td><td>Write - File speichern</td></tr>
<tr><td>:q</td><td>Quit - geht nur wenn gespeichert</td></tr>
<tr><td>:w!</td><td>force write - auch ohne gesetzes w (man muss natürlich der Fileowner sein)</td></tr>
<tr><td>:q!</td><td>force quite - ohne zu speichern</td></tr>
<tr><td>:e!</td><td>re-edit the file (neu laden)</td></tr>
<tr><td>:r</td><td><b>r</b>ead File - aktueller Position....</td></tr>
<tr><td>:!<cmd></td><td>ein Unix Kommando ausfü;hren (CTRL-D um zurückzukommen)</td></tr>
</table>
|
Settings
Diese Angaben sollten auch in einem
.exrc-File gemacht werden können.
| Command | Action |
| :set ic | ignore case zum suchen |
| :set noic | no ignore case beim suchen |
| :set showmode | Anzeigen, wenn man im Insert-Modus ist |
| :set nu | Line numbering einschalten |
| :set nonu | Line numbering ausschalten |
Quellen