Difference between revisions of "Vi"

From Linuxintro
imported>ThorstenStaerk
imported>ThorstenStaerk
 
Line 1: Line 1:
 +
= replace =
 +
:1,%s/old text/new text/g
 +
1 -> first line
 +
 +
$ -> last line
 +
 +
s -> replace
 +
 +
you cannot use wildcards (*,?) for the text to be replaced, but you can use e.g. [0-9]
 +
 +
= concatenate lines =
 +
Press J, it concatenates the actual and the next line.
 +
 +
= repeat last action =
 +
In the order mode, press ..
 +
 
= block-based actions =
 
= block-based actions =
 
u undoes the last action
 
u undoes the last action

Latest revision as of 08:36, 19 February 2010

replace

:1,%s/old text/new text/g

1 -> first line

$ -> last line

s -> replace

you cannot use wildcards (*,?) for the text to be replaced, but you can use e.g. [0-9]

concatenate lines

Press J, it concatenates the actual and the next line.

repeat last action

In the order mode, press ..

block-based actions

u undoes the last action

  1. CTRL_v and mark lines in the block mode
  2. CTRL_i insert the wished items
  3. ESC