Vim + colors inside ConEmu under windows.

1,178 views
Skip to first unread message

Grégory Pakosz

unread,
Sep 24, 2013, 6:21:48 AM9/24/13
to vim...@googlegroups.com
Hello,

Under Windows, I'm using ConEmu + Vim (either Git bash's vim or vim.exe from the Vim 7.4 Windows installer).

ConEmu is a really great console program for Windows that happens to have kind of xterm 256 colors support.

Inside my .vimrc, I added the following:

if !empty($CONEMUBUILD)
set term=xterm
set t_Co=256
let &t_AB="\e[48;5;%dm"
let &t_AF="\e[38;5;%dm"
endif

So far so good, I'm happily using Vim with colors inside ConEmu.

However, set term=xterm breaks arrow keys (and also keypad).

As Vim's documentation mentions, Vim under Windows doesn't really understand term being set to something else than 'win32'.

At that point I'm kinda stuck. ConEmu + Vim won't display nice colors unless the configuration lines above are used. For instance not setting term to 'xterm' makes Vim display " ←[38;5;15m←[48;5;233m" escape sequences straight.

From there, I would like to know whether I can improve the hack by "somehow fixing termcaps"

For instance, I noticed in src/term.c:472 defines:

{K_UP, "\316H"},
{K_DOWN, "\316P"},
{K_LEFT, "\316K"},
{K_RIGHT, "\316M"},


So within Vim inside ConEMU I tried:

set t_ku="\316H"

That totally doesn't work. Also something strange happens:

1. :set t_ku? --> answers " t_ku <Up> ^[O*A"
2. :set t_ku="\316H" --> nothing happens
3. :set t_ku? --> E518: Unknown option: t_ku?

At that point, I realize many Vim behaviors may be conditioned by term being "win32" or by term being "xterm".

All in all is one of the following doable when inside ConEmu?

1. set term=xterm and "fix arrow keys"
or
2. keep term=win32 and "fix color display by fixing t_AB, t_AF etc so that it behaves like xterm"

I know it all sounds hairy, but please let me know if you have an idea on how to improve the Vim inside ConEmu situation.

Thank you,
Gregory

Tony Mechelynck

unread,
Sep 24, 2013, 7:51:04 AM9/24/13
to vim...@googlegroups.com
Well, you'll have to find out which terminal ConEmu is trying to
"emulate". Apparently not xterm.

Vim under Windows should understand, as a minimum, the terminal names
compiled in it. Which ones they are can be seen in the top third of the
output of :version, as follows:

-builtin_terms
No terminal names built-in; Vim will rely on what your
system provides.
+builtin_terms
Only the most common ones
++builtin_terms
A rich collection ;-) .

To be able to use 256 colors, ":set t_Co=256" should be enough; but then
you need a colorscheme or plugin to use those 256 colors, otherwise all
you have is a fancy 16-color terminal. One problem under Windows is that
terminal Vim for Windows is not GUI-enabled, so I don't know if CSApprox
will be able to render GUI colors on even a 256-color Windows terminal.

If "windows" doesn't work (even with t_Co=256), try term=ansi which is a
general-purpose terminal. If your Windows console has been correctly set
up, it should understand ANSI control codes.


Best regards,
Tony.
--
"It is precisely because it is fashionable for Americans to know no science,
even though they may be well educated otherwise, that they so easily fall
prey to nonsense. They thus become part of the armies of the night, the
purveyors of nitwittery, the retailers of intellectual junk food, the
feeders on mental cardboard, for their ignorance keeps them from
distinguishing nectar from sewage."
[Isaac Asimov, "The Armies of the Night"]

Grégory Pakosz

unread,
Sep 24, 2013, 8:18:50 AM9/24/13
to vim...@googlegroups.com
> Well, you'll have to find out which terminal ConEmu is trying to
> "emulate". Apparently not xterm.

Well I think ConEmu doesn't really try to emulate a specific term.
I don't know much of ConEmu internals but I would say it's mostly win32 + "hybrid xterm like color compatibility"

That said, set term=xterm works surprisingly well: text is displayed and laid out correctly, with colors. It's just the arrow keys and keypad (likely some other keys) which don't work.

> To be able to use 256 colors, ":set t_Co=256" should be enough; but then
>

Nope, to be able to use 256 colors with ConEmu, the configuration I originally posted is required.

Gregory

Nikolay Pavlov

unread,
Sep 24, 2013, 10:34:52 AM9/24/13
to vim...@googlegroups.com


On Sep 24, 2013 2:50 PM, "Grégory Pakosz" <gregory...@gmail.com> wrote:
>
> Hello,
>
> Under Windows, I'm using ConEmu + Vim (either Git bash's vim or vim.exe from the Vim 7.4 Windows installer).
>
> ConEmu is a really great console program for Windows that happens to have kind of xterm 256 colors support.
>
> Inside my .vimrc, I added the following:
>
> if !empty($CONEMUBUILD)
>   set term=xterm
>   set t_Co=256
>   let &t_AB="\e[48;5;%dm"
>   let &t_AF="\e[38;5;%dm"

These are correct lines for setting an option.

> endif
>
> So far so good, I'm happily using Vim with colors inside ConEmu.
>
> However, set term=xterm breaks arrow keys (and also keypad).
>
> As Vim's documentation mentions, Vim under Windows doesn't really understand term being set to something else than 'win32'.
>
> At that point I'm kinda stuck. ConEmu + Vim won't display nice colors unless the configuration lines above are used. For instance not setting term to 'xterm' makes Vim display " ←[38;5;15m←[48;5;233m" escape sequences straight.
>
> From there, I would like to know whether I can improve the hack by "somehow fixing termcaps"
>
> For instance, I noticed in src/term.c:472 defines:
>
>     {K_UP,              "\316H"},
>     {K_DOWN,            "\316P"},
>     {K_LEFT,            "\316K"},
>     {K_RIGHT,           "\316M"},
>
>
> So within Vim inside ConEMU I tried:
>
> set t_ku="\316H"
>
> That totally doesn't work. Also something strange happens:
>
>   1. :set t_ku? --> answers " t_ku <Up>        ^[O*A"
>   2. :set t_ku="\316H" --> nothing happens

And this sets t_ku to an empty string because " starts a comment.

>   3. :set t_ku? --> E518: Unknown option: t_ku?
>
> At that point, I realize many Vim behaviors may be conditioned by term being "win32" or by term being "xterm".
>
> All in all is one of the following doable when inside ConEmu?
>
>   1. set term=xterm and "fix arrow keys"
> or
>   2. keep term=win32 and "fix color display by fixing t_AB, t_AF etc so that it behaves like xterm"
>
> I know it all sounds hairy, but please let me know if you have an idea on how to improve the Vim inside ConEmu situation.
>
> Thank you,
> Gregory
>

> --
> --
> You received this message from the "vim_use" maillist.
> Do not top-post! Type your reply below the text you are replying to.
> For more information, visit http://www.vim.org/maillist.php
>
> ---
> You received this message because you are subscribed to the Google Groups "vim_use" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+u...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

Grégory Pakosz

unread,
Sep 24, 2013, 11:34:19 AM9/24/13
to vim...@googlegroups.com
Hello ZyX,

> >   1. :set t_ku? --> answers " t_ku <Up>        ^[O*A"
>
> >   2. :set t_ku="\316H" --> nothing happens
>
> And this sets t_ku to an empty string because " starts a comment.

Oh right. I overlooked that.
Well I tried let &t_ku="\316H" but then Vim tells me E355: Unknown option: t_ku.

I see you commented on http://stackoverflow.com/a/14434531/216063, do you happen to know if there's something I can try on Vim's side to improve the arrow keys situation?

Regards,
Gregory
Reply all
Reply to author
Forward
0 new messages