Vim Tips Wiki
(Change to TipImported template + severe manual clean)
(adding terminals category)
Line 54: Line 54:
   
 
----
 
----
  +
[[Category:Terminals]]

Revision as of 19:54, 11 December 2007

Tip 699 Printable Monobook Previous Next

created April 12, 2004 · complexity intermediate · author Yakov Lerner · version 6.0


This tip applies only to non-GUI Vim running in xterm under X11/XWindows (linux, unix or cygwin).

When you want to use Vim's 'clientserver' features, you have this problem with non-GUI Vim under xterm: In Vim under xterm, 'servername' is disabled by default even when 'clientserver' feature is compiled into Vim.

This is different from GUI gvim, where 'servername' is enabled by default.

1. If you want to enable 'servername' for vim/xterm, the first thing to check is whether vim has 'clientserver' feature compiled-in: do ':version' and check for +clientserver; or do

'vim -h| grep servername'
in shell. If 'clientserver' is compiled in, proceed to step 3.
If 'clientserver' is not compiled in, you have several choices:
  • symlink vim to gvim (if you have gvim installed).
  • install vim with 'clientserver' support from binaries
  • build vim from sources with clientserver support and install it

2. After you checked that vim has 'clientserver' compiled in, there are several methods to enable 'servername' for vim/xterm. Methods are listed below:

  • Method (A) If you the want simplest solution, just define shell aliases:
  • For csh/tcsh: alias vim 'vim --servername vim'
  • For bash/ksh: alias vim='vim --servername vim'
The drawback of this method is that when vim will not have servername enabled when started from a script.
  • Method (B) When you're non-root user and vim is installed system-wide by sysadmin:
  1. create directory $HOME/myvim: mkdir $HOME/myvim
  2. add directory $HOME/myvim to your $PATH, but make sure it appears in the PATH the first, before all other directories, or at least before the directory where vim is installed (command 'which vim' tells you where)
  3. do 'which vim'. Remember directory where system-wide vim is installed. You'll use name of this directory in the next step, in the 2nd line of the script.
  4. create script called 'vim' in directory $HOME/myvim, with these 2 lines:
<tt>#!/bin/sh</tt>
<tt>exec /usr/local/bin/vim --servername vim "$@"</tt>
NB: you *must* use full pathname in the 2nd line of the script
  1. chmod a+x $HOME/myvim/vim
  2. if your shell is tcsh/csh, do 'unhash'
  • Method (C) When you are root user and you want to enable 'server' for all users; or when you are non-root user and you installed vim yourself under your $HOME:
  1. find out where vim is installed: % which vim
  2. cd to the directory where vim is installed
  3. remember name of this directory, you'll use in the nest step in the 2nd line of the script:
  4. in same directory, create script called 'vim.s' with this contents:
<tt>#!/bin/sh</tt>
<tt>exec /usr/local/bin/vim.bin --servername vim "$@"</tt>
NB: you *must* use full pathname in the 2nd line of the script
  1. chmod a+x vim.s
  2. mv vim vim.bin
  3. mv vim.s vim
The drawback of this method is that when you reinstall Vim, you need to repeat the renaming.

Comments