Vim plugin for coloring macros - vim

Is there any way to highlight defined variables or macros in Vim? Is there any plugin which does that. For example:
#define MONITORING_OFF 0
change_monitoring(MONITORING_OFF);
In the above example, is there any way to highlight MONITORING_ON?
(I am using Vim on windows with ctags enabled.)
Thanks

It is worth to mention Easytags plugin that, in addition to automatic
tags file update, supports dynamic syntax highlighting of tags occurrences.

Related

Vim: What's the best way to have markdown automatically enabled for comments?

I would like to be able to format comments in code somewhat:
# **TODO**
#
# *Don't forget*
I want markdown syntax to be highlighted a bit but only in comments, add cterm=bold for \*\*(.*)\*\* or something.
Is there a way to do it in Vim?
To do this properly, you'd have to :syntax include the markdown syntax into each individual syntax (that has comments that you're interested in), and have it containedin= the corresponding syntax group for comments. That's doable, but requires some effort (depending on how many and which syntaxes to modify).
It's quicker to use a plugin like my SyntaxRange plugin to change the syntax of those comment blocks to markdown (manually, and on demand). With a corresponding mapping, this can be set up quite easily (but it's not automatic as the first alternative).

Vim syntax highlighting of inline markdown

Is there any current vim plugin that allow me to highlight markdown text in a comment block of any arbitrary languages. And is that possible?
Have a look at my SyntaxRange plugin. It is based on Different syntax highlighting within regions of a file, and provides a :[range]SyntaxInclude markdown command as well as functions to do so programmatically.

Enabling markdown highlighting in Vim

I'm using Vim in a terminal on my MacBook Air with OS X Lion, and I can't seem to find a good plugin for Markdown syntax highlighting.
So far I've tried the plasticboy plugin and Tim Pope's plugin. The plasticboy plugin worked OK but was causing white space at the end of lines to be highlighted, and I haven't figured out how to turn that off. (It's really annoying, because every time I hit space when I'm writing it highlights the character.)
Tim's plugin didn't seem to do very much in the way of highlighting, other than maybe headers that use ###. Code blocks and bullets are ignored. I might be missing something there. I do use the .md extension on my Markdown files, so it should be picking up the filetype.
I've also seen a reference to Vim 7.3 having Markdown support built in, but without one of those two plugins I don't get any highlighting at all.
Do either of these require specific color schemes to work?
About the native syntax highlight for markdown I think it only works for files with the extension .markdown by default.
I was having problems with markdown syntax highlight for my .md files.
I tried:
:set syntax=markdown
And it worked.
So i included the following line in my .vimrc:
au BufNewFile,BufFilePre,BufRead *.md set filetype=markdown
Now my vim have syntax highlight for my .md files.
BufFilePre is needed for :sav
Native syntax highlighting
Native syntax highlighting for Markdown only works by default for the .markdown file extension.
The following line in .vimrc yields the best results for both vim and gvim:
autocmd BufNewFile,BufFilePre,BufRead *.md set filetype=markdown.pandoc
Explanation:
1. Specify your Markdown flavour!
If you work with mainly one flavour of Markdown (e.g. Pandoc), be sure to mention this as well! Doing so, allows for mixing and matching of both Markdown- and Pandoc-specific Vim plug-ins. For example: I have found the vim-pandoc-syntax plug-in particularly suitable for my highlighting needs. Nevertheless, I use the more general vim-markdown-folding for Markdown folding.
By the way, only one flavour is allowed, separated by a dot, e.g.: filetype=markdown.pandoc
2. gvim requires BufFilePre
gvim requires an additional BufFilePre in the autocommand line for Markdown file type recognition with the Save As… :sav command.
This should work to disable the end-of-line space highlighting when using the plasticboy mkd plugin:
:syn clear mkdLineBreak
You could autocmd that for the necessary file extensions so that you needn't do it every time you load a markdown file.
Note that this specific highlight exists because Markdown treats lines ending with 2 or more space characters specially by inserting a <br>, so it is useful.
The plasticboy plugin uses TODO highlighting for this rule, which is a bit too much as it's designed to, by default, be really garish - yellow background - so that it stands out. You can make this less visually striking by changing that highlight rule. One quick way to do this would be something like:
:hi link mkdLineBreak Underlined
Now those end-of-line spaces will show up as underlined. Try linking to other highlight groups for something that may appeal to you more. Instead of using link you can get even more specific about those end-of-line spaces: for instance you could specify that they show up as just slightly lighter/darker than the normal background, using your own highlight command, specifying custom ctermfg, ctermbg, guifg, guibg settings.
As above, you could autocmd this to apply your specific settings.
For more information about link highlight groups, type: :help group-name and you'll see a list of groups that can be linked that themselves should helpfully be displayed using their current highlight rules. Also: :help highlight.
In Tim's plugin the .md extension works only for README.md because filetype.vim specifies so.
" Markdown
au BufNewFile,BufRead *.markdown,*.mdown,*.mkd,*.mkdn,README.md setf markdown
If you don't like putting all of your configuration in ~/.vimrc, you can create ~/.vim/ftdetect/markdown.md (or its equivalent on Windows) with the following contents.
au BufNewFile,BufRead *.md setf markdown

Folding of text in vim with Markdown syntax plugin

I have a Markdown syntax highlighting plugin installed for Vim (MacVim). It's working well, but it automatically folds down headings, lists, etc.
Does anyone know how to disable the folding of sections completely with a plugin like this? I just want to be able to open Markdown documents without having every section collapsed every time...
Since this question popped up first in my search, I'll duplicate zeuxcg's answer from this question:
set nofoldenable " disable folding

Auto formatting for vi?

Does an auto-formatting tool exist for vi that'll allow me to define per language preferences?
edit: I'm not looking for syntax highlighting. I'm looking for something that will apply formatting rules to my code. (Like brace positioning, spaces around oeprators, etc)
Well, there's Vim which comes with a lot of languages covered already and which is easy to customize per language.
Vim has tons of support for filetype-specific customisations. You might find what you are looking for in there.
You can add a file in ~/.vim/ftplugin/ for each file type. For example, set ~/.vim/ftplugin/c.vim to
set tabstop=2 shiftwidth=2
This sets your indentation for C files to two spaces.
You can use vim. If you're on GNU/Linux, take a look at /etc/vim/vimrc for global defaults. Some things you may want are "syntax on" "filetype indent on" and "set showmatch".
There is a vim plugin that enables formatting on your code from within vim. It's called vim-autoformat and you can dowload it here:
https://github.com/vim-autoformat/vim-autoformat
It integrates external code-formatting programs into vim. For example, if you want to format C, C++, C# or Java code, you can install the program astyle, and vim sets it as the format program automatically.
As Darrin says, "flee from the vi wasteland" and embrace the one true vim path instead! Your desired language preferences, assuming that they're not for SNOBOL or Simula, will thank you!
Edit: Actually extending the syntax highlighting to cover SNOBOL or Simula would not be that hard! (-:

Resources