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.

Skiminok
  • 165

2 Answers2

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.

Maximus
  • 20,835
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