Hi Gerald

> Given a new buffer with these 2 lines:
> 
> 1x2x3x4x
> 5x6x7x8x
> 
> Put cursor on "1". Then type:
> 
>    v3:<C-u>/x<CR>
> 
> where <C-u> is Ctrl-u and <CR> is Enter.
> 
> Shouldn't the cursor be on the "x" between "3" & "4" instead of on "5",
> just like you would with typing:
> 
>    3/x<CR>
> 
> instead ?
>
This behaviour of Vim has nothing to do with its visual mode, but
with its history. To do want you want, type

v3/x<CR>

without any colon(:).

If you type a colon(:), you must enter an ex-command -- by observing
its syntax rules: Every ex-command can be preceded by one or two
line numbers. The simplest ex-command is "go to a line", which can
be entered simply by the corresponding line number. E.g. ":7<CR>"
(without quotes) go to line 7.

Instead of entering line numbers, you can also enter regular
expressions. E.g. ":/x<CR>" go to the first line _after_ the current
line that contains the regular expression "x". ":/x/,/y/d<CR>
deletes all lines from the first containing x to the first
containing y. Here, the part /x/,/y/ specify a range.

This syntax was first introduced by the old "ed" editor and is valid
yet in the "sed", "ex" and "vi" editor -- and may be others. So much
to the history of Vim!

I hope this clarifies your point.

Best regards

Mathias

Reply via email to