7

I love vim, i use it all the time for write codes, but now I want to write some personal notes.

I'm trying vim-pandoc (with vim-pandoc-syntax) and it's nice to have 'rich text' features like titles, items, bold, italic fonts and even tables, but doen't have 'arbitrary colored text'. For the colored text I have tried txtfmt but this plugin uses special characters for the colors and I cant read them on others computers using the same configuration files (home and work computers).

Is there some alternative to txtfmt to achieve colored text? More explicitly: how can I highlight some arbitrary part of my text with colors?

4 Answers 4

2

@Ingo Karkat Your Txtfmt files should look the same on different computers. If they don't, it could be that Vim is using a different encoding on the different computers (e.g., utf-8 vs latin-1), and you haven't set Txtfmt's 'tokrange' option explicitly. Recommended approach is to set 'tokrange' to a value that will work on all your systems in a "Txtfmt modeline" in the file itself. This prevents Txtfmt from picking a default (which could be different on different systems). Example:

txtfmt:tokrange=180X
vim:ft=txtfmt

Note: The example above places all Txtfmt tokens near the end of the latin-1 char set. If you can force use of utf-8 on all your systems (e.g., by setting Vim's encoding option in your vimrc), you might do this instead...

txtfmt:tokrange=0xE000X
vim:ft=txtfmt

...which places all Txtfmt tokens in the Unicode "Private Use Area".

:help txtfmt-'tokrange'
:help txtfmt-modeline
1
  • 1
    @EvergreenTree Note that there's a section in the vim-notes help on embedding Txtfmt highlighting within notes. More generally, the Txtfmt plugin supports "nesting" Txtfmt highlighting within other types of syntax regions. You could even highlight your C comments if you really wanted to. ;-)
    – BPS
    Jun 4, 2015 at 15:48
1

It really depends on where you want to read those documents. Inside Vim, you can define your own syntax highlighting, and then have any sort of words or marked-up text highlighted according to Vim's capabilities. That makes it non-portable, though: You need to have your syntax script around.

For a portable, no-install solution, you need an external viewer, anyway. The most common, lowest-denominator one today is the web browser. Using HTML markup, you can easily (if not as succinctly as Markdown) format your documents, and use arbitrary colors and formats (and with CSS even animations and other gimmicks).

4
  • The idea is write, the note, in Vim and only read it in Vim, so i prefer a syntax solution. I was hoping someone wrote something like what i need, i really dont know how to write that jaja May 20, 2015 at 20:47
  • 1
    For me, the txtfmt plugin then looks perfect for this. It uses (invisible) markdown for the colors, but this has to be stored somewhere, and languages like HTML do it in a similar way. May 20, 2015 at 20:54
  • But i cant read the same file in two different places with the same configuration. for example, in my home computer i wrote something like a nice red text but in my office computer i read 'µ' were should be the 'invisible red'. So i supose that txtfmt use some non-portable special characters May 20, 2015 at 21:07
  • Yes, the µ seems to be the markup character for red. Are you sure you have the txtfmt plugin installed on each computer? May 21, 2015 at 6:43
1

Have you tried any note taking plugin ? I use vim-notes for personal notes and I think it does its job very well.

1
  • 1
    This plugin doesn't seem to allow arbitrary text highlighting as specified in the question, thought it does have its own syntax highlighting. May 29, 2015 at 18:29
0

On the pandoc webpage, they write

vim-pandoc doesn't provide syntax support. The user needs to install vim-pandoc/vim-pandoc-syntax alongside it (see below). The reason for this is we have found cleaner to keep the bug tracking of the syntax file and the rest of the system separate.

Have you tried that? From what I can understand, they provide a syntax support with their other source.

2
  • @bilbo_pingoin Yeah, sorry i should be more specific. i edit my question. The thing is how can i highlight with colors some arbitrary part of my text? May 20, 2015 at 20:50
  • 1
    Then you are probably back to @Ingo Karkat's suggestion: get you own syntax file. You can google around to see if someone already made one, but it is not that complicated to write a simple one. Once you're done, you can place it somewhere on the web (github?) to pass it from one place to another. May 20, 2015 at 20:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.