Thursday, May 16, 2019

Re: searching my selection with * with vnoremap by Gary Johnson or modifying * by Andy Wokula

On mer., 2019-05-15 at 09:44 +0200, Mathieu Roux wrote:
> Good morning,
>
> In the same vein i posted before, now i want to use * to search one
> path in this way.
>
> if i position my cursor on the line:
> '/abc/def/ghi/klm'
> of localisation, where
> abc is the part
> def is the chapter
> ghi is the section
> klm is the subsection
>
> When i press F5 (or another touch) when my cursor is on "abc", i want
> to search the lines beginning with "abc".
> When i press F5 (or another touch) when my cursor is on "def", i want
> to search the lines beginning with "abc/def".
> When i press F5 (or another touch) when my cursor is on "ghi", i want
> to search the lines beginning with "abc/def/ghi".
> When i press F5 (or another touch) when my cursor is on "klm", i want
> to search the lines beginning with"abc/def/ghi/klm".
>
> I have already posted it on this group before (but not exactly the
> same), but i tried something, and i don't know why it does not work:
>
> map <F5> vf/F'*
>
> selection to the next / and back to '
>
> A few problems appear:
>
> 1) Only the second point is taken into account (F'), and not (f/)
>
> 2) the condition for f should be / OR ', and not only /
>
> 3) i want to leave visual mode when i do *
>
> Can you help me?
> Best regards,
> Mathieu Roux
>



I think i am near the solution now, but it is not already finished.

The best way to begin is maybe to use vnoremap given by Gary Johnson a
few days ago.

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>


It is ok to search an entire line with: 0v$*.
But i want something more sophisticated.
Then i need something like:
map <F5> v0f('|/)*


but there are problems as i mentionned before:
i want to selection in visual mode from the beginning of the lign, and
to the first character which is ' or / that is find.
I bet that i have to escape /. But i don't know how i can do this.
:he keycodes
suggest me to use <kDivide> but it does not work...
Maybe f is not the recommanded to cut my line... i don't know...


Or maybe i should use something like the script mtc147.vim by Andy
Wokula?

I just need a little bit stream edition on my line, and then i just do
*.
Can you help me?

Best regards,
Mathieu Rouc

--
--
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/726d194d1064bbd653af3fd8181a2bf6e5e2677a.camel%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment