Mike's face
Sunday, July 12th, 2020

Vim + xterm

Sunday June 19, 2005 22:22

A few configuration files to get xterm and Vim under xterm to work well.

I'm posting my .Xresources and .vim* files here.  You may have to adjust the flavors slightly to your own taste.
I'll refresh them from to time to time.  Feel free to ask any questions or provide improvements and/or corrections (which never happens anyway).

Here's my .Xresources file:

XTerm*utf8: 1

XTerm*background: black
XTerm*foreground: white
XTerm*transparent: false
XTerm*shading: 40
XTerm*geometry: 180x70
XTerm*font:     -mike-*-*-*-*-*-13-*-*-*-*-*-*-*
XTerm*boldFont: -mike-*-*-*-*-*-13-*-*-*-*-*-*-*
!xterm*font:     *-lucidatypewriter-medium-*-12-*-75-*
!XTerm*VT100*font: -misc-fixed-medium-r-normal--18-120-100-100-c-90-iso10646-1
XTerm*boldMode: false
XTerm*charClass:	33:48,37:48,45-47:48,64:48,126:48
XTerm*metaSendsEscape: true
XTerm*backingStore: WhenMapped
XTerm*color0: black
XTerm*color1: #bb0000
XTerm*color2: green3
XTerm*color3: #aa7700
XTerm*color4: #3377ff
XTerm*color5: magenta3
XTerm*color6: cyan3
XTerm*color7: gray90
XTerm*color8: gray30
XTerm*color9: #ff0000
XTerm*color10: #00ff00
XTerm*color11: #ffff00
XTerm*color12: #66aaff
XTerm*color13: magenta
XTerm*color14: cyan
XTerm*color15: white
XTerm*colorUL: green4
XTerm*colorBD: blue3

And my .vimrc file:

map <C-A> <ESC>

"nn <silent> K mk:exe 'match Search /<Bslash>%'.line(".").'l.*'<CR>
set statusline=%<%f\ %h%1*%m%*%r%=%-14.(%l,%c%)\ %P
hi User1 term=inverse,bold cterm=inverse,bold ctermfg=red

set encoding=utf-8
"set fileencoding=utf-8
set fileencodings=utf-8

"filetype plugin on

"taglist plugin
set updatetime=1000

"java_apidoc plugin
let browser="xterm -e links"
let javadoc_path="/home/mike/public_html/docs/j2sdk-1_5/api,/home/mike/public_html/docs/jdom,/home/mike/public_html/docs/j2sdkee1.3.1-api,/home/mike/public_html/docs/rhino-api"
map <C-A>k viw"ky:call OpenJavadoc("k")<CR>
"map <C-A>k :call OpenJavadoc("<cword>")<CR>
function! Debug(a)
"	echo a:a "

set term=xterm
""set t_ti=^[7^[[r^[[?47h
"set t_ti=^[7^[[?47h
""set t_te=^[[?47l^[8
"set t_te=^[[2J^[[?47l^[8
set t_ti=7[?47h t_te=[?47l8

set t_Co=16
set t_AF=[%?%p1%{8}%<%t3%p1%d%e%p1%{22}%+%d;1%;m
set t_AB=[%?%p1%{8}%<%t4%p1%d%e%p1%{32}%+%d;1%;m

"set t_Co=8
""set t_AB=[%?%p1%{8}%<%t%p1%{40}%+%e%p1%{92}%+%;%dm
""set t_AF=[%?%p1%{8}%<%t%p1%{30}%+%e%p1%{82}%+%;%dm
"set t_AF=[%?%p1%{8}%<%t3%p1%d%e%p1%{22}%+%d;1%;m
""set t_AF=[%?%p1%{8}%<%t3%p1%d%e%p1%{22}%+%d;1%;m
""set t_AB=[%?%p1%{8}%<%t4%p1%d%e%p1%{32}%+%d;1%;m
set nobackup
set vb t_vb=
set autoindent
set cino=:0
set nosmartindent
set nocindent
set comments=
set bs=1
set formatoptions=tcq2
set iskeyword=!-~,^*,^|,^\"
set shiftwidth=4
set tabstop=4
set nowrap
set nocompatible
set tw=1024
set scrolloff=5
set sidescrolloff=5
set ss=1
set mouse=a
set nostartofline
set shellcmdflag=-lc
set splitright
set showcmd
set tags=./tags,tags,$JAVA_HOME/src/tags
set winwidth=150
set winheight=50
set winminwidth=0
set winminheight=0

"map <Esc>[M<space> jjjjjjjjjjjjj
"map <Esc>[M<space> 4<C-E><ESC>[M.
"map <Esc>[M# 4<C-Y><ESC>[M.

"map <Esc>[M# <MouseUp>
"  Wheel up:           ESC[M#
"    Wheel down:         ESC[M$      (gnome terminal sends ESC[Mspace)
	"    Ctrl+wheel up:      ESC[M3
	"    Ctrl+whele down:    ESC[M4      (gnome terminal sends ESC[M0)

map <ESC>[ZA 8<C-y>
map <ESC>[ZB 8<C-e>

"set mouse=
"set mousemodel=extend
"map <M-Esc>[62~ <MouseDown>
"map! <M-Esc>[62~ <MouseDown>
"map <M-Esc>[63~ <MouseUp>
"map! <M-Esc>[63~ <MouseUp>
"map <M-Esc>[64~ <S-MouseDown>
"map! <M-Esc>[64~ <S-MouseDown>
"map <M-Esc>[65~ <S-MouseUp>
"map! <M-Esc>[65~ <S-MouseUp>
"map <M-Esc>[62~ <MouseDown>

map <M-Esc>[62~ <MouseDown>
map! <M-Esc>[62~ <MouseDown>
map <M-Esc>[63~ <MouseUp>
map! <M-Esc>[63~ <MouseUp>
map <M-Esc>[64~ <S-MouseDown>
map! <M-Esc>[64~ <S-MouseDown>
map <M-Esc>[65~ <S-MouseUp>
map! <M-Esc>[65~ <S-MouseUp>

"map <MouseDown> 3
"map <S-MouseDown> 6
"map <M-Esc>[62~ jj
"map <M-Esc>[64~ jj
"map <Esc>[M# jj

map <MouseDown> 8<C-y>
map <MouseUp> 8<C-e>

set notbs
set nohlsearch
set incsearch
set dict=/usr/share/dict/words
set thesaurus=/usr/share/apps/thesaurus/thesaurus.txt
set path=.,$PWD,/usr/include,$HOME/a7/dev/src/java,$HOME/aurora2/dev/src/java
"set isf=@,48-57,/,.,-,_,+,,,#,$,%,~
set isf=@,48-57,/,.,-,_,+,#,$,%,~

if filereadable("build.xml")
exec "set makeprg=antfiltered"

" ant only
"set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m,
"	   \%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#

" ant and grep

"set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m,
"	   \%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#,
"	   \%f:%l

"if filereadable("files")
"set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m,
"	   \%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#,
"	   \%f:%l
"set efm+=%f:%l:%v:%*\\d:%*\\d:%*\\s%m

"if filereadable("files")
"set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m,
"	   \%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C%.%#,
"	   \%f:%l
"set efm+=%A%f:%l:\ %m,%-Z%p^,%-C%.%#
"set efm+=%f:%l:%v:%*\\d:%*\\d:%*\\s%m

if filereadable("build.xml")

"set efm=\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m,
"\%A\ %#[javac]\ %f:%l:\ %m,%-Z\ %#[javac]\ %p^,%-C\ %#[javac]\ symbol\ \ :\ %m,%-C%.%#,
"\%A%f:%l:\ %m,%-Z%p^,

set efm=
\\ %#[javac]\ %#%f:%l:%c:%*\\d:%*\\d:\ %t%[%^:]%#:%m,
\%A\ %#[javac]\ %f:%l:\ %m,
\%-Z\ %#[javac]\ %p^,
\%-C\ %#[javac]\ symbol\ %#:\ %m,
\%A%f:%l:\ %m,


"set ssop=blank,buffers,curdir,folds,help,winsize
set ssop=blank,buffers,curdir,folds,help
set vb
"syn region myFold start="{" end="}" transparent fold
"syn sync fromstart
"set foldmethod=syntax
"autocmd BufRead *.txt set tw=78

" jump to previous cursor position
autocmd BufReadPost * if line("'\"") | exe "'\"" | endif

"autocmd BufReadPost * set indentexpr=|set nosmartindent|set nocindent|set comments=

iab 1t try<CR>{<CR>}<CR>catch (Throwable ex)<CR>{<CR>}<ESC>O	m_logger.log(Level.SEVERE, ex);<ESC>3kO
iab 1p System.out.println);<C-O>h
iab 1l m_logger.info(");<C-O>2h
"iab 1L LOGGER.LOGID("<ESC>bbgDwwye''$pA",);<C-O>h
"iab 1L LOGGER.LOGID(<C-X><C-L><ESC>0f,lC);<C-O>h
iab 1s {<CR><TAB><ESC>o}<ESC>2k3==2jO
"iab 1( (<ESC>%a
iab 1{ {<CR>}<ESC>O
iab 1[ {<CR>}<ESC>YP$C
iab 1i for (Iterator i =.iterator(); i.hasNext(); )<CR>{<CR>}<ESC>kk3Wa<C-H>
iab 1j for (Iterator j =.iterator(); j.hasNext(); )<CR>{<CR>}<ESC>kk3Wa<C-H>
iab 1I for (int i = 0; i <; i++)<CR>{<CR>}<ESC>kk8wa<C-H>
iab 1J for (int j = 0; j <; j++)<CR>{<CR>}<ESC>kk8wa<C-H>
iab 1x for (int x = 0; x <; x++)<CR>{<CR>}<ESC>kk8wa<C-H>
iab 1y for (int y = 0; y <; y++)<CR>{<CR>}<ESC>kk8wa<C-H>
iab 1n <ESC>Bye$pb~A = (<C-O>p)i.next();<ESC>3B
set ignorecase
set smartcase

syntax on
map Q gq
map <C-Z> u
map <C-X> <C-R>
map <C-B> P
map <C-J> 4j
map <C-K> 4k
map <C-H> 10zh
map <C-L> 10zl
map <C-M> :wall<CR>:mak run
"map <F2> :wall<CR>:mak
"map <F3> :wall<CR>:mak deploy
"map <F4> :wall<CR>:mak quick
"map <F5> :wall<CR>:mak verify
map <F9> :set mp=makefiltered<CR>
map <F10> :set mp=antfiltered<CR>
map <C-P> :cp<CR>
map <C-N> :cn<CR>
map <C-A>a .
map <C-A><C-A> <C-A>a
map <C-A>d :!tkdiffabs <cfile><CR>
map <C-A><C-D> <C-A>d
map <C-A>w :w<CR>
map <C-A><C-W> <C-A>w
"map <C-A>t mmOOtry
catch (Throwable ex)
map <C-A>t mmOOtry
catch (Throwable ex)
	m_logger.log(Level.SEVERE, ex);ko}ddp'm^
map <C-A><C-T> <C-A>t
map <C-A>z :wa<CR>:mks!<CR>:set t_ti=<CR>:set t_te=<CR>:qa<CR>
map <C-A><C-Z> <C-A>z
map <C-A><SPACE> :!<CR>
map <C-A>j :grep <cword> `cat files`<CR>
map <C-A>J :grep -r <cword> ~/j<CR>
map <C-A><C-J> <C-A>j
map <C-A>m :!mc -a <cfile>:h <cfile>:h<CR>
map <C-A><C-M> <C-A>m
map <C-A>x I:+!\Yuok@"
map <C-A><C-X> <C-A>x
map <C-A>p :e ~/tmp/.tmp<CR>
map <C-A><C-P> <C-A>p
map <C-A>o :sp ~/d/fragments.java<CR>
map <C-A><C-O> <C-A>o
map <C-A>r :!jsfilter<CR>
map <C-A>R :!phpfilter<CR>
map <C-A><C-R> <C-A>r
map <C-A>c mxo<ESC>O<C-U>/*<ESC>`xo<C-U>*/<ESC>
"map <C-A>C mxo<ESC>O<ESC>i<!--<ESC>`xo<C-U>--><ESC>
map <C-A>C mxo<ESC>O<ESC>i<C-U><!--<ESC>`xo<C-U>--><ESC>
map <C-A>v m'0<C-V>I//<ESC>''ll
map <C-A>V :s/^\/\//<CR>
map <C-A>s mxo>><ESC>O<C-H>{<ESC>`xo<C-H>}<ESC>=%
noremap P P`[
"noremap P mmP`m
"noremap P mm>>`mp<<`m
"noremap Y mmY`m
"map P ma<C-Q>P
"map <C-Q>P mmP'm
map . .`[
"map <C-A>h :set noic<CR><C-W>sgd:set ic<CR>b<C-]>
map <C-A>h <C-W>s*GNB<C-]>
map <C-A>f ma:e<CR>'a:cd <cfile>:h<CR>gf
map <C-A>/ :set hlsearch<CR>
map <C-A>? :set nohlsearch<CR>
map <C-A>l :diff<CR>:redraw!<CR>
map <C-A>= :sp /usr/local/share/vim/vim61/syntax/colortest.vim<CR>:source %<CR>
map <C-A>$ :#!renamejava % <cword>
map <C-A>g Y6P^jdWj.jj.j.kkkkkIpublic WW~gewigetA()
{jI	return m_A;
}jIpublic void setl~A(JxA)
{jI	m_A =JA;
}jIprivate wwim_A;
noremap <C-A><C-N> :w<CR>:cn<CR>
noremap <C-A><C-P> :w<CR>:cp<CR>
map <C-A>] :if exists("b:did_indent")<CR>unlet b:did_indent<CR>endif<CR>:source $VIMRUNTIME/indent/xml.vim<CR>
map <C-A>[ :set indentexpr=<CR>
map <C-A>y mmYP'm
map <C-A>9 <ESC>`<i(<ESC>`>la)<ESC>`<
map <C-A>i <ESC>i(()<ESC>mmea)<ESC>`mi
map <C-W>t :Tlist<CR><C-W>h
map <SPACE> :cc<CR>
map ' `
map <C-T> :tn<CR>
map <C-MiddleMouse> <LeftMouse>gf
map <C-LeftMouse> <LeftMouse><C-]>
map <C-RightMouse> <C-O>
map gF :execute("!mkfile <cfile>")<CR>gf
map gP :execute("!convert -verbose <cfile> /dev/null")<CR>
map g<C-P> :execute("!gqview <cfile>")<CR>
map gp :e %:h<CR>
map gn /^"= <CR>W:e <cfile>
map gG :execute("!gimp <cfile> &")<CR>

map <TAB><INS> :pclose<CR>:execute("!writeport 9876 bs % ".line("."))<CR>
map <TAB><DEL> :pclose<CR>:execute("!writeport 9876 bc % ".line("."))<CR>
map <TAB><S-DEL> :pclose<CR>:execute("!writeport 9876 bc")<CR>
map <TAB><SPACE> :pclose<CR>:execute("!writeport 9876 st % >/tmp/.v")<CR>:cfile /tmp/.v<CR>
map <TAB>b :pclose<CR>:execute("!writeport 9876 bl % >/tmp/.v")<CR>:cfile /tmp/.v<CR>
map <TAB>s :pclose<CR>:execute("!writeport 9876 s % >/tmp/.v")<CR>:cfile /tmp/.v<CR>
map <TAB>i :pclose<CR>:execute("!writeport 9876 i % >/tmp/.v")<CR>:cfile /tmp/.v<CR>
map <TAB>o :pclose<CR>:execute("!writeport 9876 o % >/tmp/.v")<CR>:cfile /tmp/.v<CR>
map <TAB>r :pclose<CR>:execute("!writeport 9876 r % >/tmp/.v")<CR>:cfile /tmp/.v<CR>
map <TAB>p m':execute("!writeport 9876 p <cword> >/tmp/.v")<CR>'':pedit /tmp/.v<CR>

"  \df : opens a third window on top with the diff file.
"  \dr : re-runs diff on new/old files
"  \dc : synchronize windows to current  diff, cursor at new->old diff section
"  \dC : synchronize windows to current  diff, cursor at old->new diff section
"  \dn : synchronize windows to next     diff
"  \dp : synchronize windows to previous diff
"  <F8>: same as \dn
map \df :let lzs1=&lz<CR><C-W>k<C-W>s:ene<CR>:exe "0r !diff -c ".expand("#1")." ".expand("#2")<CR>:set nomod<CR>:set ft=diff<CR>gg:let &lz=lzs1<CR>
map \dr :let lzs2=&lz<CR>2<C-W>k:exe "0r !diff -c ".expand("#1")." ".expand("#2")<CR>:set nomod<CR>:set ft=diff<CR>gg:let &lz=lzs2<CR>\dn
map \dc	:let lzs3=&lz<CR><C-W>k<C-W>k?^\*\{15}$<CR>jYpdwf,DAGz<C-V><CR><Esc>"bYdd<C-W>j@b<C-W>k?^\*\{4}<CR>/^--- <CR>Ypdwf,DAGz<C-V><CR><Esc>"aYdd2<C-W>j@a2<C-W>k?^\*\{3} <CR>z<CR>:set nomod<CR>:let &lz=lzs3<CR>:echo "diff converts middle window to lower window"<CR>
map \dC \dc/^--- <CR>z<CR>:echo "diff converts lower window to middle window"<CR>
map \dn :let lzs4=&lz<CR><C-W>k<C-W>k/^\*\{15}$<CR>j\dc:let &lz=lzs4<CR>
map \dp	:let lzs5=&lz<CR><C-W>k<C-W>k?^\*\{15}$<CR>?<CR>j\dc:let &lz=lzs5<CR>

function! <SID>OutlineToggle()
let OldLine = line(".")
let OldCol = virtcol(".")
if (! exists ("b:outline_mode"))
let b:outline_mode = 0
let b:OldMarker = &foldmarker
" :echo confirm(b:OldMarker)
" if search("{>>", 'w') == 0
" " no modifed marker found, must be normal marker mode
" let b:outline_mode = 0
" else
" let b:outline_mode = 1
" endif

if (b:outline_mode == 0)
let b:outline_mode = 1
" syn region myFold start="{" end="}" transparent fold
" syn sync fromstart
" set foldmethod=syntax
" set foldmethod=indent

set foldmethod=marker
set foldmarker={,}

silent! exec "%s/{<</{<</"
silent! exec "%s/}>>/}>>/"
let b:outline_mode = 0
set foldmethod=marker
let &foldmarker=b:OldMarker
" set foldmarker={<<,}>>

silent! exec "%s/{<</{<</"
silent! exec "%s/}>>/}>>/"

execute "normal! ".OldLine."G"
execute "normal! ".OldCol."|"
unlet OldLine
unlet OldCol
execute "normal! zv"

"* Commands
:command! -nargs=0 OUTLINE call <SID>OutlineToggle()

map zz :OUTLINE<CR>
"nmap <silent> gw "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<cr><c-o><c-l>
map gw "_yiw:s/\(\%#\w\+\)\(\W\+\)\(\w\+\)/\3\2\1/<cr><c-o>
map gW wbdt,ma])Pi, 'adw

set loadplugins
runtime .vim/*.vim

hi StatusLine ctermfg=Red
hi StatusLineNC ctermfg=DarkRed
hi VertSplit ctermfg=DarkRed


set cino=:0

hi javaConst ctermfg=1 guifg=#888
hi javaMember ctermfg=12 guifg=#888
hi javaObject ctermfg=15 guifg=#888
hi javaClass ctermfg=11 guifg=#888

hi javaOperator ctermfg=13 guifg=#888
hi javaParen ctermfg=1 guifg=#888
hi javaParen1 ctermfg=2 guifg=#888
hi javaParen2 ctermfg=5 guifg=#888
hi javaComment ctermfg=3 guifg=#888
hi javaLineComment ctermfg=3 guifg=#888
hi javaType ctermfg=4 guifg=#888
hi javaStatement ctermfg=6 guifg=#888
hi javaExceptions ctermfg=6 guifg=#888
hi javaRepeat ctermfg=6 guifg=#888
hi javaConditional ctermfg=6 guifg=#888
hi javaLabel ctermfg=6 guifg=#888
hi javaBranch ctermfg=6 guifg=#888
hi javaUserLabel ctermfg=13 guifg=#888

hi Search ctermbg=1

syn keyword type void float mike
syn match javaOperator "[.=\-\+\*/~!%^&|,<>\[\]]"
syn cluster javaTop add=type,javaMember,javaObject,javaClass,javaConst
syn match javaObject "[a-z][a-zA-Z0-9_]*"
syn match javaMember "[a-z]_[a-zA-Z0-9_]*"
syn match javaConst "[A-Z_][A-Z0-9_]*"
syn match javaClass "[A-Z][a-zA-Z0-9_]*[a-z][a-zA-Z0-9_]*"

I also use the following plugins, which you can find on vim.org:

  • jad.vim
  • java_apidoc.vim
  • ZoomWin.vim
  • taglist.vim

(C) Copyright 2004-2007 Mike Pot