Hacker News new | ask | show | jobs
by ramses0 11 days ago
Another slew of utility lies in `:help searchoffset`, often like the following: https://til.codeinthehole.com/posts/about-vims-semicolon-sea...

    /x/e-3
    /x/+1
    /x/;/yz
...it allows near arbitrary cursor placement (eg: this blog articles "squiggle" situation) to be able to find the beginning of the squiggle, or the end of the squiggle (or temporarily using "X" and "Z" for start/end, and "clearing" it with `V...:s/[XY]/./g`
2 comments

For the last example given in that article:

    /test_.*_errors/;/errors
I find it much easier to use "\zs". That tells vim where you want the "start" of the match to be. Everything before the "\zs" is just treated like context:

    /test_.*_\zserrors
It is also useful for ":s/match/sub"
Noice! :-D Never knew about that (even though it might be vim-specific), but yeah, so much easier than where I'll usually have to do some trial + error to get my cursor to land where I want it. (usually in a macro, or multi-`.` edit context).
Love it, this was new to me
It's one of those things you'd _never_ stumble over naturally, but once you're aware of the concept, it makes a ton of sense and you can immediately think of tons of uses for it.

    /def new_.*(/s+8
    /2026-/e
    /except/+1;/raise