I'm a simple user of vi. But now I'm looking for a bit more sophisticated solution. What I've in mind should look like a vimdiff view, but it's not about diffs.
My first view has a file open with lines having one 'key' string as part of each line.
The second view is read-only showing another file. This one has each key exactly one time in that file embedded in a line.
The following behaviour I'm looking for
now without any further user activity
find the key string within this line
search this key within the second view
scroll to this line to become the center of view 2
highlight line (or key) in view 2
If someone can give me a starting point or what might be available already?
thanks in advance
Wolfgang R.
This should be possible without tags, however you will need a custom function or a macro which does something like that:
/key:\s\zs.*\ze\s
(this assumes you are searching for the value in a key: value
combination).*
<c-w>l
n
<c-w>h
Go
you can use that:
:let @a = '/key:\s\zs.*\ze\s^M*^Wln^WhGo
to save it to register a
. Important is that ^M
has to be entered with <c-v><cr>
and ^W
has to be entered with <c-v><c-w>
.