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

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

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

Daniel Fetchinson
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

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CADjSo4SKp83eXjPAn6xoqEGj12OVMakyVg0kT-kh%3DAJ7JOT6uA%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

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

Daniel Fetchinson
> 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

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/CADjSo4SEUe80quaZiPoPXJtKr0x3Fu4-PzfaohXLaPAw9y4aFQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

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

Paul-7
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.

--
--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/vim_use/20201228162930.GA30924%40rainslide.net.

signature.asc (817 bytes) Download Attachment