How to enable 256-color console Vim syntax highlight in ConEmu

256-colors vim in ConEmu

Requirements

  • Only certain releases are supported;
  • 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. Of course, you need some 256-color vim scheme, it is ‘zenburn’ in the last line of this example.
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

You may also check environment variable ConEmuANSI but I’m not sure how to do that properly.

Only certain releases are supported

NB ‘Original’ Win32 console executable Vim from gvim##.exe and vim##w32.zip passed tests (versions 7.3 and 7.4 were tested).

If you would like to use cygwin, msys, or WSL Vim versions you shall use connector to let ConEmu emulate POSIX terminal. Otherwise WSL, MinGW’s and Cygwin’s Vim do not pass ANSI to ConEmu.

Notes about vim color schemes

Selected Vim color scheme must be prepared specially for Xterm color. Some color schemes are working properly in Gvim, showing 256 colors and more, but if they aren’t aware about xterm sequences, they will fail in the console vim.

If you have problems with certain color scheme, please contact it’s author.

Color scheme mentioned above (zenburn) is working fine.

Fix Vim’s BS issue

If you have problems with BS in Vim (BS acts like Delete key) under ConEmu when term=xterm, you may try to remap BS key:

inoremap <Char-0x07F> <BS>
nnoremap <Char-0x07F> <BS>

If BS still acts like Delete the problem may be with plugins. Find problem plugins and disable them.

:verbose map <bs>
:verbose map <c-h>

Check for details in the issue 641.

How to enable Vim scrolling using mouse Wheel in ConEmu

Since ConEmu build 170730 all mouse events are posted as XTerm sequences when XTerm mouse mode was requested by console application.

So all you need to add following lines to your vimrc file:

""""""""""""""""""""""""""""""""""""""
" let mouse wheel scroll file contents
""""""""""""""""""""""""""""""""""""""
if !has("gui_running")
    set term=xterm
    set mouse=a
    " perhaps `nocompatible` is not required
    set nocompatible
endif

If you have problems with Vim configuration, you may refer to the Issue 1007.

vim-airline plugin

StackOverflow and SuperUser answers

Install Vim8 in Bash on Ubuntu on Windows