Vim Tips Wiki
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
FANDOM
Fan Central
BETA
Games
Anime
Movies
TV
Video
Wikis
Explore Wikis
Community Central
Start a Wiki
Don't have an account?
Register
Sign In
FANDOM
Explore
Current Wiki
Start a Wiki
Don't have an account?
Register
Sign In
Sign In
Register
Vim Tips Wiki
1,649
pages
Explore
Main Page
All Pages
Community
Interactive Maps
Community portal
To do
Editing
Using vim color schemes with Putty
Back to page
Edit
Edit source
View history
Talk (0)
Edit Page
Using vim color schemes with Putty
We recommend that you
log in
before editing. This will allow other users to leave you a message about your edit, and will let you track edits via your
Watchlist
.
Creating an account
is quick and free.
The edit appears to have already been undone.
Anti-spam check. Do
not
fill this in!
{{TipNew |id=1576 |previous=1575 |next=1577 |created=2008 |complexity=basic |author=Timkebox |version=7.0 |subpage=/200806 |category1=Syntax |category2=Terminals }} I am using '''PuTTY''' in Windows to access a Unix box, and the Terminal-type string in PuTTY is set to '''xterm'''. I wanted to use '''Vim's color schemes'''. I tried many different things with no decent result until I found the following code in Vim's help. After inserting the following lines in my [[vimrc]], I was able to use all the color schemes defined by Vim. For a 16-color display: <pre> if has("terminfo") let &t_Co=16 let &t_AB="\<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm" let &t_AF="\<Esc>[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm" else let &t_Co=16 let &t_Sf="\<Esc>[3%dm" let &t_Sb="\<Esc>[4%dm" endif </pre> {{help|xfree-xterm}} For an 8-color display: <pre> if &term =~ "xterm" if has("terminfo") let &t_Co=8 let &t_Sf="\<Esc>[3%p1%dm" let &t_Sb="\<Esc>[4%p1%dm" else let &t_Co=8 let &t_Sf="\<Esc>[3%dm" let &t_Sb="\<Esc>[4%dm" endif endif </pre> ==Alternative== With the settings below, using <code>:runtime syntax/colortest.vim</code> shows all 23 colors as distinctly unique. Putty settings: Window, Colours :[x] Allow terminal to specify ANSI colours :[x] Allow terminal to specify xterm 256-colour mode :[x] Bolded text is a different colour Settings in vimrc: <pre> if &term =~ "xterm" " 256 colors let &t_Co = 256 " restore screen after quitting let &t_ti = "\<Esc>7\<Esc>[r\<Esc>[?47h" let &t_te = "\<Esc>[?47l\<Esc>8" if has("terminfo") let &t_Sf = "\<Esc>[3%p1%dm" let &t_Sb = "\<Esc>[4%p1%dm" else let &t_Sf = "\<Esc>[3%dm" let &t_Sb = "\<Esc>[4%dm" endif endif </pre> ==See also== *[[VimTip25|Color highlighting on telnet]] *[[VimTip1291|Desert color scheme with Vim in PuTTY]] ==Comments== It is relatively easy to change the TERM setting PuTTY uses to set it to send it as "xterm-256color" (or install the full set of terminfo files and set it to the proper setting of "putty-256color". -- PuTTY doesn't support Techtronix mode and so is not fully xterm compatible.) In PuTTY this is changed in the Configuration in the Connection -> Data section. This is the same preferences page where you specify your auto-login username, so you should be visiting this page anyway. With your auto-login username specified, and public key authorization (which you should be using) and a key agent running (PuTTY's Pageant does this) you can select a host and log in without being prompted for username or password. With your TERM set to anything close to accurate, you can then leverage all 256 colors in other applications without manually tweaking the settings for every application. [[User:Steven Black|Steven Black]] 17:49, December 9, 2010 (UTC) ---- I often use PuTTY at work to connect to a solaris box which we use for compiling code. I have no admin rights, and no knowledge of how to set up terminfo, etc. I tried the PuTTY setting you give, but I just get a "using dumb terminal mode" message on login, and Vim has no colors. The 256-color workaround in this tip works fine. I don't like it, I'd rather do it "the right way" but sadly this may not be an option for me. Unless there's something I can do in my own user space to get the terminfo correct. --[[User:Fritzophrenic|Fritzophrenic]] 19:28, December 9, 2010 (UTC) ---- Chances are your system doesn't use terminfo then. Try hardwiring your term option like this: :set term=builtin_xterm or :set term=builtin_ansi That should give you colors in putty. Your vim needs to be compiled with +builtin_term (+ or ++), though. [[User:Chrisbra|Chrisbra]] 20:50, December 9, 2010 (UTC) ---- Thanks for the suggestion. I have +builtin_terms (not ++builtin_terms) but neither :set term=builtin_xterm nor :set term=builtin_ansi have any noticeable effect to enable colors, even when it is the first item in the .vimrc (after :set nocompatible). Since the hack in this tip does work for me, and I really don't know much about terminal configuration, I'm probably going to just leave it. --[[User:Fritzophrenic|Fritzophrenic]] 14:24, December 10, 2010 (UTC) ---- : It works for me with putty. But I need to explicitly set :syntax on after setting 'term' to builtin_ansi. [[Special:Contributions/217.88.63.38|217.88.63.38]] 13:20, December 11, 2010 (UTC) ---- Try to set Terminal-type string in putty (Connection->Data) to 'putty-256color'. That worked for me.
Summary:
Please note that all contributions to the Vim Tips Wiki are considered to be released under the CC-BY-SA
Cancel
Editing help
(opens in new window)
Templates used on this page:
Template:Help
(
view source
)
Template:Navigation
(
view source
)
Template:TipNew
(
view source
)
Follow on IG
TikTok
Join Fan Lab