Skip to content

Instantly share code, notes, and snippets.

@markusfisch
Created August 5, 2012 18:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markusfisch/3266482 to your computer and use it in GitHub Desktop.
Save markusfisch/3266482 to your computer and use it in GitHub Desktop.
Configure vim and xterm to look and behave like GVim

Configure vim and xterm to look and behave like GVim

If you like to have an extra window for editing files with vim, you may either install/use GVim or you can simply make vim run inside xterm.

Setup

You'll need (at least) VIM 7.3 and XTerm 276.

To open vim in its own window, you may complete your ~/.bashrc with that snippet:

# XVim, what's GVim again? :)
#
# @param ... - files to open
xvim()
{
	local F=$@

	if [[ `vim --serverlist` == *XVIM* ]]
	then
		vi --servername xvim --remote ${F[*]} &>/dev/null
	else
		xterm -class xvim -e "vi --servername xvim ${F[*]}" &>/dev/null &
	fi
}

After reloading your bash configuration you may type

$ xvim some-file

to open "some-file". Subsequent invocations will add the given files to the already open window so you can copy/paste between buffers.

Make it look good

The popular Solarized color scheme (http://ethanschoonover.com/solarized) works just fine if you configured xterm AND vim to use 256 colors.

For xterm, open (or create) ~/.Xdefaults and add (or change) the resource termName to xterm-256color. Here's a sample with configurations that go well with the dark flavour of Solarized:

xterm*background: #1c1c1c
xterm*foreground: white
xterm*highlightColor: #323232
xterm*faceName: Luxi Mono
xterm*faceSize: 8
xterm*scrollBar: false
xterm*colorBDMode: false
xterm*visualBell: false
xterm*saveLines: 512
xterm*termName: xterm-256color

For vim, open (or create) ~/.vimrc and add this BEFORE you're setting the color scheme:

syntax on
set background=dark
let g:solarized_termcolors=256
color solarized

Using PieDock?

If you're using PieDock (https://github.com/markusfisch/PieDock), you probably want the XVim window to have its own icon. To distinguish xvim from xterm, add this alias to ~/.piedockrc:

alias class "xvim" xvim

Now you just need a nice icon called xvim.png in your icon path. Check that SVG icon below.

Display the source blob
Display the rendered blob
Raw
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment