Monday, May 6, 2019

Re: searching one word containing # with touch *

On 2019-05-06, Mathieu Roux wrote:
> On dim., 2019-05-05 at 12:35 -0700, Gary Johnson wrote:
> > On 2019-05-05, Mathieu Roux wrote:
> > > On dim., 2019-05-05 at 18:50 +0200, Tony Mechelynck wrote:
> > > > On Sun, May 5, 2019 at 6:44 PM Mathieu Roux wrote:
> > > > >
> > > > > Hello,
> > > > > I would like to search the word under my prompt on vim. For
> > > > > this, i
> > > > > can press touch *.
> > > > > But, if the word i want to search is #foo, as an exemple, vim
> > > > > only
> > > > > searches word foo (without hashtag).
> > > > > 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.
> > > > > Mathieu Roux
> > > >
> > > > see :help *
> > > But 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.
> >
> > :set iskeyword+=#
> > :set iskeyword+=-
> >
> > seems to do it.
> >
> > Regards,
> > Gary
> >
> > --
>
> Great! it seems to work...!
> Maybe you also know how i can search one whole lign with vim?
> Of course, i can use visual mode to select the lign, and then press *,
> but is there one faster solution?

For that, I usually do

0v$*

If you wanted something faster, you could map that to some unused
key sequence or to a function key.

I should add that I have * in visual mode mapped to a sequence of
commands that escape special characters in the visually-selected
region so that those characters don't corrupt the search pattern.

vnoremap <silent> * :<C-U>
\let old_reg=getreg('v')<bar>
\let old_regmode=getregtype('v')<cr>
\gv"vy/<C-R><C-R>=substitute(
\escape(@v, '\\/.*$^~[]'), '\n', '\\n', 'g')<cr><cr>zv
\:call setreg('v', old_reg, old_regmode)<cr>

To give credit where credit is due, that and some related mappings
were posted to the vim list in 2003 by Jürgen Krämer. I may have
made some minor modifications since.

Regards,
Gary

--
--
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.
For more options, visit https://groups.google.com/d/optout.

No comments: