Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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.

share|improve this question
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 '13 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 '13 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 '13 at 6:16
add comment

1 Answer

up vote 0 down vote accepted

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

share|improve this answer
    
Is there any vim on Windows that supports both xterm-256 colors and enter/leave sequences? msysgit? mingw? –  Skiminok Feb 22 '13 at 23:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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