Christian Brabandt wrote:
Hi Rahul!
On Mi, 13 Okt 2010, Rahul wrote:
I maintain a simple Todo file using vim. Each line has a task.
Sometimes for an important task it would be nice if I had a keystroke
that would make the whole line (or visually selected set of lines) a
particular color, say "Red".
Is there a way of setting this up? I've colored before but it is via a
Syntax File looking for keywords. That might also work in this case
but I was wondering if people have a way to dot this.
I have never used it, but this sounds like you want the txtfmt plugin.
http://www.vim.org/scripts/script.php?script_id=2208
Brett will probably tell you in more detail about that plugin (Let's see
if mentioning the plugin name works, to get his attention ;))
Worked like a charm! ;-) Yes, Rahul, you could certainly use Txtfmt for
this purpose. Txtfmt gives you a sort of rich text highlighting
capability in any sort of text file: you can apply foreground and
background colors, as well as all combinations of bold, underline,
italic, etc... You can even nest Txtfmt regions within other file types.
So, for example, if you had a syntax named "todo" for your TODO lists,
you could do...
:setfiletype todo.txtfmt
...to allow arbitrary highlighting of the text within individual TODO
items. If you decide to give it a try, I'd recommend taking 5 or 10
minutes to go through the "Quick-Start Tutorial" on the download page.
Ordinarily, the highlighting tokens are inserted with an intuitive set
of mappings, but Txtfmt also provides a feature called "user maps",
which allows you to combine the various insert-token and jump-to-token
primitives together into sequences, which can then be mapped to a single
keystroke. So, for example, if you wanted a quick way to make all the
text on a line red bold-italic on a blue background, and then to center
the text on the line, you could define a Txtfmt user map that does all
this and assign it to any keystroke you like (e.g., <F8>). You can make
the logic within a user map as simple or as complex as you like. You can
even define different sets of user maps for different types of file. The
Txtfmt help provides a number of examples...
:help txtfmt-user-maps
:help txtfmt-user-map-examples
If the examples don't make it clear, I'd be more than happy to offer
advice tailored to your particular use-case...
Sincerely,
Brett Stahlman
regards,
Christian
--
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