3

enter image description here

Is there any way to change the syntax highlighting in vimwiki in windows. I could not properly see the line enclosed between [[some word]]. The same works well in Linux.

  • 2
    This shouldn't change much between OSs. Is there any chance you are using some colorscheme on linux and forgot to set it when using windows? (check :echo g:colors_name) – mMontu Mar 7 '16 at 11:06
  • the pink kind of highlighting remains for all colorscheme in windows – neelabalan Mar 7 '16 at 15:19
4

I think this is because Windows' cmd.exe has very limited support for colours; you can only use 16, and those 16 are different from what Unix terminals use (which mostly support at least 256 colours nowadays).

The easiest solution is to just use Gvim. Windows is not designed to be used from the commandline, and doesn't really support it very well.

You can change the colours with the highlight command:

  • First figure out which syntax highlight group is being used by going to the highlighted word with the cursor and:

    :echo synIDattr(synID(line("."), col("."), 1), "name")`
    

    This should give you a name such as pythonConditional.

  • When using :highlight pythonConditional you can see the attributes set for this as well as a short preview. In the case of pythonConditional it links to another highlight group: Conditional, which links to Statement, which looks like:

    Statement      xxx term=bold ctermfg=3 gui=bold guifg=Brown
    
  • By using :highlight pythonConditional <attributes> we can set attributes. For example :highlight pythonConditional ctermfg=red would make the text red.

  • To make these changes permanent you need to add them to your vimrc file; but to make sure that it's not override by a filetype or colorscheme command, you'll typically want to do this in an autocmd:

    autocmd FileType python highlight pythonConditional ctermbg=green guibg=green
    

Also see the Vim documentation at :help :highlight and :help :autocmd

2

I have found a way to work 256 colors in windows using ConEmu, link available here for download.

After setting up ConEmu, check for these conditions -

  • Vim’s executable must be named ‘vim.exe’;

  • Check options ‘Inject ConEmuHk’ and ‘ANSI X3.64 / xterm 256 colors’ on Features page

  • Check option ‘TrueMod (24bit color) support’ on Colors page

  • Edit your ‘vimrc’ file, sample lines are here.

The following code is to be added to vimrc file.

if !has("gui_running")
    set term=xterm
    set t_Co=256
    let &t_AB="\e[48;5;%dm"
    let &t_AF="\e[38;5;%dm"
    colorscheme zenburn
endif

Of course, you need some 256-color vim scheme, it is ‘zenburn’ in the last line of this example.

Now I have no syntax highlighting issues when using vim in ConEmu. Check the link for the official documentation.

  • It would be helpful if you could provide a description of what you did in the answer itself. That way, the answer will also be useful to future readers, even after that link might be dead :-) Thank you! – Martin Tournoij Mar 10 '16 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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