searching my selection with *

13 views
Skip to first unread message

Mathieu Roux

unread,
May 15, 2019, 3:44:56 AM5/15/19
to vim...@googlegroups.com
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

Mathieu Roux

unread,
May 16, 2019, 10:32:09 AM5/16/19
to vim...@googlegroups.com
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

Reply all
Reply to author
Forward
0 new messages