On Sat, Jan 14, 2023 at 1:55 PM Stan Brown <[email protected]>
wrote:
> > While possibly not quite what you're looking for, if I want such, I
> use
> > ...> :50,100g/cat/#
> >
> > Tim, this doesn't do what I'm trying to do, but the bigger problem is
> > that :g absolutely moves the cursor, putting it on the last found match.
>
> I use :g as Tim does. I don't particularly want the cursor moved, but
> after looking at the results I simply type `` and the cursor is back
> where it was.
>
I'm not questioning the utility of this at all; I use various versions of
this myself. However, I was trying to build something that could be used in
a script, not something I'm using to examine the results from the
command-line.
Since you and Tim took time out to respond, here's a version I use for the
word under the cursor, in case you find a use for it. It prints all lines
that have the word under the cursor with a number before them and then
prompts you for the number, jumping to the specified result:
nmap <F4> [I:let nr = input("Which one? ")<Bar>if nr > 0<bar>execute
"normal " . nr ."[\t"<bar>endif<CR>
If you prefix the last [ with a \<c-w> (inside the quotes), it'll jump to
that line in a new split, instead, retaining your current cursor location.
All the best,
Salman
--
--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_use/CANuxnEery5bbsQhRHGePgt7%2Ba5Yt%2BK%2ByMT4zU9f0bgyu2K%2BYAw%40mail.gmail.com.