3

I'm trying to bring to work together 3 things: ConEmu, Cygwin and vim. The vim in question is not Cygwin vim, but the native Windows vim from gvim package (chosen because Cygwin vim does not support xterm 256 colors). 256-color syntax highlighting seems to work after I followed the instructions on StackOverflow, but I cannot solve another problem.

Cygwin vim works fine with alternate screens: when I exit it, the screen content is cleared and I can see my command history back again. Windows vim does not: when I exit it, the command prompt appears underneath the page of former vim content. This question has been asked several times on StackOverflow and SuperUser: here, here, here and here. However, none of the solutions in these questions seem to work in ConEmu/Cygwin. I tried:

  • setting t_ti and t_te in my .vimrc as follows:

    let &t_ti="\e[?47h"
    let &t_te="\e[?47l"
    
  • or:

    let &t_ti="\e[?1049h"
    let &t_te="\e[?1049l"
    
  • enabling altscreen on in .screenrc. I'm not sure that it was supposed to have any effect at all, since I didn't even have screen installed in Cygwin. Installing it didn't change anything, though. Explicitly launching vim with screen brings weird results: half of escape sequences and codes and broken, not every keypress is recognized, and the console dimensions are ~80x40 regardless of screen arguments.

My $TERM in vim currently is xterm, as it has been set in .vimrc config required to enable 256 color support in ConEmu. However, sending xterm-like escape sequences does not seem to clear screen whatsoever.

I'd very glad for any help with this issue.

3
  • 1
    Cygwin vim does support 256 color mode in the default terminal (mintty) as well as xterm and (u)rxvt. It can't support it in the builtin Windows console because that's inherently limited to 16 colours. In mintty and xterm, TERM has to be set to xterm-256color to enable it. In mintty, that can be done on the Terminal page of its options.
    – ak2
    Feb 23, 2013 at 5:46
  • Yes, I can do it in mintty. However, for some reason it doesn't work in ConEmu even though ConEmu supports xterm-256.
    – Skiminok
    Feb 23, 2013 at 5:51
  • ConEmu primarily is a wrapper around the Windows console. The console is limited to 16 colours and doesn't support terminal escape sequences, so in order to support 256 colours, ConEmu uses some special trickery: it injects a DLL into the program running in it, which hooks the Windows API calls for writing to the console and intercepts colour control escape sequences. Meanwhile, the Cygwin DLL does its own parsing of escape sequences, to make a Windows console behave like a Unix terminal when Cygwin program write() to it. Hence those sequences never make it to the console API and hence ConEmu.
    – ak2
    Feb 23, 2013 at 6:16

2 Answers 2

0

AFAIK vim (Windows version) does not post to terminal enter/leave alternative mode sequences. Don't know how mintty deals with it, still investigating.

1
  • Is there any vim on Windows that supports both xterm-256 colors and enter/leave sequences? msysgit? mingw?
    – Skiminok
    Feb 22, 2013 at 23:47
0

Try setting this in your .vimrc, which also enables the scroll wheel in vim.
This came from http://conemu.github.io/en/Whats_New.html, the build 150316 notes. It seemed to finally fix this issue for me.

""""""""""""""""""""""""""""""""""""""
" let mouse wheel scroll file contents
""""""""""""""""""""""""""""""""""""""
if !has("gui_running")
    set term=xterm
    set mouse=a
    set nocompatible
    inoremap <Esc>[62~ <C-X><C-E>
    inoremap <Esc>[63~ <C-X><C-Y>
    nnoremap <Esc>[62~ <C-E>
    nnoremap <Esc>[63~ <C-Y>
endif

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .