How to move to the next match in VIM?

I have a file I'm working on, where I need to make a lot of changes. The text before what I need to change is permanent, but what I need to change is changing. What I'm doing now is /my_constant_text, and nto go to the row that I need to edit. But using n, like this, I still have to move the cursor forward compared to my matched text in order to get to where I want to start editing. It seems to me that there should be a way only on my cursor to just go through my agreed text, but I was not lucky to find it.

If this helps the file I'm working on, it looks like the next two lines are repeated many times with different values.

INSERT INTO TABLE (ID, NAME, VALUE) VALUES ('1','foo','all sorts of random stuff')
INSERT INTO TABLE (ID, NAME, VALUE) VALUES ('2','bar','some other random stuff')

I want to be able to move my cursor right after 'foo','(i.e. my_constant_text).

+5
source share
3 answers

Use /constant_text/eto jump to the end of a permanent text, or /constant_text/e+1to jump immediately after it.

+10
source

Things can be more universal http://vimdoc.sourceforge.net/htmldoc/pattern.html# {offset}

[...]  With "/" and "?" an
additional offset may be given.  There are two types of offsets: line offsets
and character offsets.  {the character offsets are not in Vi}

The offset gives the cursor position relative to the found match:
    [num]   [num] lines downwards, in column 1
    +[num]  [num] lines downwards, in column 1
    -[num]  [num] lines upwards, in column 1
    e[+num] [num] characters to the right of the end of the match
    e[-num] [num] characters to the left of the end of the match
    s[+num] [num] characters to the right of the start of the match
    s[-num] [num] characters to the left of the start of the match
    b[+num] [num] identical to s[+num] above (mnemonic: begin)
    b[-num] [num] identical to s[-num] above (mnemonic: begin)
    ;{pattern}  perform another search, see |//;|
+2
source

As Jan said, use the '/ e' modifier. If it's more complicated, but just a search bar, there are always macros

qanf,q

to save the macro nf,(this will be your complex stuff, not just that nf,) in the macro a, and then

@a

to call him.

0
source

All Articles