Search code examples
regexvimcursor-positiontext-cursor

Vim regex searching: alter placement of cursor in matched strings


I frequently use the vim regex /\. (note the trailing space) as a quick and (very) dirty way to identify new sentences. I would like the cursor to jump to the space, rather than the period when I type n or N.

Generally, how can I control the placement of the cursor in regex matches?


Solution

  • You can define where the match should start with \zs (see :help \zs), so /\. \zs would leave the cursor on the first letter of the next sentence (ie. equivalent to the ) sentence motion) and /\.\zs (note trailing space) would leave it on the space.