Sunday, July 26, 2020

Re: How can I find where one word is close to another word?

Tim,

I haven't tried your code, yet, but I was wondering about this followup: 

Would it be possible to essentially parametrize your command in vimrc, so that I could do something like this?

/ps/firstword/secondword/distance

I'm using 'ps' for 'proximity search', but if that's already a taken command, we'd have to make it something else. 

Many thanks for your help!

Cheers,
Adrian

On Saturday, July 25, 2020 at 8:41:55 PM UTC-5, Tim Chase wrote:
On 2020-07-25 17:54, Adrian Keister wrote:
> There's an answer on the Stack Exchange site. Does that method work
> also?

That method finds only the case in which you have "aid" *followed by*
"country", so if you have

  "This country needs all good men to come to her aid."

it won't find that even though "country" and "aid" are within 10
words of each other.

You might recognize that it's pretty similar to the first half of my
2nd answer:  "term1(N optional words)term2" which I then swap around
with "or term2(N optional words)term1".

So if you only need "X with Y following it within N words", that's
an easy solution.  If you need to allow for arbitrary ordering of the
words, you need a bit more such as either of my suggestions.

-tim



--
--
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 vim_use+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/b24310f6-98e1-44a1-b35a-cbeedc810de2o%40googlegroups.com.

No comments:

Post a Comment