-1

I would like to search the word under my prompt on vim. For this, i tried to press touch *. But, if the word i want to search is #foo, as an exemple, vim only searches word foo (without hashtag), so it fails.

In fact, hashtag is not considered in the word, which is confirmed when i try to go to the next word from # with w.

Do you know how i can search effectively #titi by pressing * on my keyboard?

Thanks.

  • Besides warnings about changing iskeyword consider this: how should all of the non-keyword characters that are fully or partially pattern atoms (i.e. they are special in a regex) be handled. Existing * functionality doesn't need to worry about how to handle *, ?, (, etc. That functionality would need to be well defined. – B Layer May 5 at 23:58
  • for the rare cases I need this, I usually just use g* instead of * and continue jumping using n until I find what I am looking for. – Christian Brabandt May 6 at 11:15
0

What is considered to be part of a word is defined, I think, by iskeyword. You can try to change this setting to include # and see if it solves your case.

More info: :help 'iskeyword'

  • Do be careful with this, as it does affect a lot of things – D. Ben Knoble May 5 at 17:30
  • Of course it does affect a lot of things! How can i change keywords just for # and - (i want for exemple #foo-bar to be just one word)? i tried before but i did not succeed. The problem is that i also want to use tags with CTRL + ], so maybe i cannot do set iskeyword="" as far as i understand. Mathieu – user22113 May 5 at 18:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.