Introductie

K

Kerstkonijn

De vi editor is een zeer krachtige editor. Er is ontzettend veel mee mogelijk. Toch kan er nog meer: Bram Moolenaar heeft vim gemaakt. Vi improved. Tevens de Open Source versie. Heel mooi, maar in de Dreambox zit geen vi of vim!

Daarvoor in de plaats zit BusyBox. Een soort Zwitsers zakmes met veel gebruikte Unix commando's/tools. En zoals het met zo'n zakmes mogelijk is houtjes te zagen, is het met BusyBox mogelijk te editen zoals met vi.

Dat lijkt een beperking. Toch is er met deze vi editor nog vele malen meer mogelijk dan hieronder beschreven.

[SIZE=-3]*** Edited by Kerstkonijn for finetuning only[/SIZE]
 
De Esc toets is de toets om alle opties aan te kunnen spreken. Deze toets betekent: Terminate insert mode. Iets anders doen dan gegevens invoeren? (Dus: opslaan, zoeken, plakken, verwijderen etc.)
  • Druk dan op de Esc toets!
En daar hoeft niemand zuinig mee te zijn. Er gaat niets fout als er per ongeluk meerdere keren op Esc gedrukt wordt

De cursor wordt bestuurd dmv:
h Links
j Naar beneden
k Omhoog
l Rechts

Maar om het niet te moeilijk te maken: de pijltjestoetsen werken ook.
 
Beginnen

vi [naam van de te editen / maken file]


Opslaan en Afsluiten

Esc :w Enter = opslaan (write)
Esc :w! Enter = geforceerd opslaan
Esc :q Enter = verlaten (quit)
Esc :q! Enter = geforceerd afsluiten: ook als niets opgeslagen is
Esc :wq Enter = opslaan en afsluiten
Esc :wq! Enter = geforceerd opslaan en afsluiten

(Vanaf nu wordt de Esc en de Enter weggelaten, omdat die nogal logisch zijn.)


Tekst invoegen

Geel = Handig om te onthouden

a Append after cursor
A Append at end of line
i Insert before cursor
I Insert at beginning of line
o Open a line below current line
O Open a line above current line
r Overwrite current caracter
R Begin overwriting tekst
s Substitute a character
S Substitute entire line


Bewerken

c Begin a change
d Begin a deletion
y Begin a yank (copy)

Het c commando kan worden gecombineerd met w:
cw change word: Het huidige woord wordt vervangen door het nieuw in te kloppen woord.

cw Change word
cc Change line
dd Delete line
d$ Delete up to end of line
d^ Delete up to begin of line
dG Delete to end of file
yy Copy line
p Paste (last deleted or yanked characters) after cursor
P Paste (last deleted or yanked characters) before cursor
x Delete character
u Undo
. Repeat last action
J Jion two lines (2 regels samenvoegen tot 1)
/ Find (Zoeken naar tekst)
n Next (Volgende zoeken)
? Previous (Vorige zoeken)
~ Reverse case (UPPERCASE > lowercase; lowercase > UPPERCASE)

[SIZE=-3]*** Edited by Kerstkonijn for finetuning only[/SIZE]
 
Tip1: Twee letters omdraaien?
xp

Tip2: Waar ben ik nu?
Ctrl-G

Tip3: Naar regel 30?
:30

Tip4: Vijf regels yanken (copy), drie keer plakken?
5yy
3p

Tip5: Twee regels omdraaien?
ddp

Tip6: Shell commando uitvoeren?
:!

Tip7: Shell commando uitvoeren en output invoegen?
!!

Tip8: Eerste string 'Microsoft' zoeken in huidige zin en vervangen door 'Linux'? :)
:s/Microsoft/Linux/

Tip9: Elke string 'Microsoft' zoeken in alle zinnen en vervangen door 'Linux'? :cool:
:g/Micr/s/Microsoft/Linux/g

Tip10: Elke regel met string 'Microsoft' verwijderen? :biggrin:
:g/Microsoft/d

Tip11: Een Control-M invoegen?
i Ctrl-V Ctrl-M

[SIZE=-3]*** Edited by Kerstkonijn for finetuning only[/SIZE]
 
(Control characters zijn cursief weergegeven, de tekst in Engels omdat dat duidelijker is ivm gekozen letter)
[SIZE=-3]Bron: Linux in a Nutshell, O'Reilly, isbn 1-56592-585-8[/SIZE]

a Append text after cursor
A Append text before cursor
A

b Back up to beginning of word in current line
B Back up one word, ignoring punctuation
B Scroll backward one window

c Change operator
C Change to end of current line
C Esc

d Delete operator
D Delete to end of current line
D Scroll down half-window; in indert mode, unindent to shiftwidth if autoindent is set

e Move to end of word
E Move to end of word, ignoring punctuation
E Show one more line at bottom of window

f Find next character typed forward on current line
F Find next character typed backward on current line
F Scroll forward one window

g
G Go to specified line or end of file
G Print information about file on status line

h Left arrow cursor key
H Move cursor to home position
H Left arrow cursor key, Backspace key in insert mode

i Insert text before cursor
I Insert text before first nonblank character on line
I In insert mode: same as TAB key

j Down arrow cursor key
J Join two lines
J Down arrow cursor key; in indert mode, move down a line

k Up arrow cursor key
K
K

l Right arrow cursor key
L Move cursor to Last position in window
L Redraw screen

m Mark the current cursor position in register (a-z)
M Move to middle position in window
M Carriage return

n Repeat the last search command
N Repeat the last search command in reverse direction
N Down arrow cursor key

o Open line below current line
O Open line above current line
O

p Put yanked or deleted text after or below cursor
P Put yanked or deleted text before or above cursor
P Up arrow cursor key

q
Q Quit vi and invoke ex (:vi Return to vi)
Q

r Replace character at cursor with the next character you type
R Replace characters
R Redraw the screen

s Change the character under the cursor to typed characters
S Change entire line
S

t Move cursor forward to character before next character typed
T Move cursor backward to character after next character typed
T In insert mode: move to next tab setting

u Undo the last change made
U Restore current line, discarding changes
U Scroll the screen upward a half-window

v
V
V In insert mode: insert next character verbatim

w Move to beginning of next word
W Move to beginning of next word, ignoring punctuation
W In insert mode: back up to beginning of word

x Delete character under cursor
X Delete character before cursor
X

y Yank or copy operator
Y Make copy of current line
Y Show one more line at top of window

z Reposiition line containing cursor (Followed by Return = reposition line to top of screen; followed by . = reposition line to middle of screen; followed by _ = reposition line to bottom of screen)
ZZ Exit the editor, saving changes
Z Suspend vi
 



Hosting Fun

Advertenties

Terug
Bovenaan Onderaan