Vim Tips Wiki
(Insert TipProposed template + minor manual clean)
(Manual edit: Changed to use let not set and thereby avoid CTRL-V and un-copy-pastability nastiness. Can't test though. Can someone else?)
Line 16: Line 16:
 
<pre>
 
<pre>
 
if has("terminfo")
 
if has("terminfo")
set t_Co=16
+
let &t_Co=16
set t_AB=<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
+
let &t_AB="\<Esc>[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm"
set t_AF=<Esc>[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
+
let &t_AF="\<Esc>[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm"
 
else
 
else
set t_Co=16
+
let &t_Co=16
set t_Sf=<Esc>[3%dm
+
let &t_Sf="\<Esc>[3%dm"
set t_Sb=<Esc>[4%dm
+
let &t_Sb="\<Esc>[4%dm"
 
endif
 
endif
 
</pre>
 
</pre>
   
  +
{{help|xfree-xterm}}
''Note that '''<Esc>''' is a real escape, type '''Ctrl-V Esc''' when you enter lines''. {{help|xfree-xterm}}
 
   
 
For an 8-color display:
 
For an 8-color display:
Line 32: Line 32:
 
if &term =~ "xterm"
 
if &term =~ "xterm"
 
if has("terminfo")
 
if has("terminfo")
set t_Co=8
+
let &t_Co=8
set t_Sf=<Esc>[3%p1%dm
+
let &t_Sf="\<Esc>[3%p1%dm"
set t_Sb=<Esc>[4%p1%dm
+
let &t_Sb="\<Esc>[4%p1%dm"
 
else
 
else
set t_Co=8
+
let &t_Co=8
set t_Sf=<Esc>[3%dm
+
let &t_Sf="\<Esc>[3%dm"
set t_Sb=<Esc>[4%dm
+
let &t_Sb="\<Esc>[4%dm"
 
endif
 
endif
 
endif
 
endif
Line 46: Line 46:
 
{{Todo}}
 
{{Todo}}
 
*Can the <Esc> note above be avoided? If not, add note about Ctrl-Q.
 
*Can the <Esc> note above be avoided? If not, add note about Ctrl-Q.
  +
*I've modified the tip to avoid it now by using let not set, but I can't test
  +
it. Could somebody else test and remove these comments?

Revision as of 06:33, 3 July 2008

Proposed tip Please edit this page to improve it, or add your comments below (do not use the discussion page).

Please use new tips to discuss whether this page should be a permanent tip, or whether it should be merged to an existing tip.
created June 29, 2008 · complexity basic · author Timkebox · version 7.0

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:

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

:help xfree-xterm

For an 8-color display:

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

Comments

 TO DO 

  • Can the <Esc> note above be avoided? If not, add note about Ctrl-Q.
  • I've modified the tip to avoid it now by using let not set, but I can't test

it. Could somebody else test and remove these comments?