Jump between phrases with particular pattern and feed matching words to command

17 views
Skip to first unread message

Fetchinson

unread,
Dec 26, 2020, 8:40:46 PM12/26/20
to vim...@googlegroups.com
Hi everybody,

I have a text file with content like this:

[example.jpg|image]
[example.pdf|document]
[another.jpg|image]
[yetanother.doc|document]

And I'd like to make vim "jump" between the 4 items back and forth via
two selected keys, for example "n" for next and "p" for previous. When
one of the items is "selected", it should be highlighted with a
background different from the default, I mean the whole item from [ to
] should have a different background. Then I'd like to be able to
press a third key, for example, Enter, which should call a vim
function with the 2 arguments given by the file name and the file
type, for example "example.pdf" and "document".

How would I go about achieving this?

--
Psss, psss, put it down! - http://www.cafepress.com/putitdown

Fetchinson

unread,
Dec 27, 2020, 9:20:09 AM12/27/20
to vim...@googlegroups.com
> I have a text file with content like this:
>
> [example.jpg|image]
> [example.pdf|document]
> [another.jpg|image]
> [yetanother.doc|document]
>
> And I'd like to make vim "jump" between the 4 items back and forth via
> two selected keys, for example "n" for next and "p" for previous. When
> one of the items is "selected", it should be highlighted with a
> background different from the default, I mean the whole item from [ to
> ] should have a different background. Then I'd like to be able to
> press a third key, for example, Enter, which should call a vim
> function with the 2 arguments given by the file name and the file
> type, for example "example.pdf" and "document".
>
> How would I go about achieving this?

What I'm looking for is a kind of browser-like behavior like
NERD_tree.vim but this is over 4000 lines of code and I couldn't
figure out how it does what it does.

Cheers,
Daniel

Paul

unread,
Dec 28, 2020, 11:29:42 AM12/28/20
to vim...@googlegroups.com
On Sun, Dec 27, 2020 at 03:20:01PM +0100, 'Fetchinson' via vim_use wrote:
>> I have a text file with content like this:
>>
>> [example.jpg|image]
>> [example.pdf|document]
>> [another.jpg|image]
>> [yetanother.doc|document]
>>
>> And I'd like to make vim "jump" between the 4 items back and forth via
>> two selected keys, for example "n" for next and "p" for previous. When
>> one of the items is "selected", it should be highlighted with a
>> background different from the default, I mean the whole item from [ to
>> ] should have a different background. Then I'd like to be able to
>> press a third key, for example, Enter, which should call a vim
>> function with the 2 arguments given by the file name and the file
>> type, for example "example.pdf" and "document".

You can achieve the first two goals with 'j', 'k', and the cursorline setting.
signature.asc
Reply all
Reply to author
Forward
0 new messages