(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:
- create directory $HOME/myvim: mkdir $HOME/myvim
- 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)
- 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.
- 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
- chmod a+x $HOME/myvim/vim
- 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:
- find out where vim is installed: % which vim
- cd to the directory where vim is installed
- remember name of this directory, you'll use in the nest step in the 2nd line of the script:
- 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
- chmod a+x vim.s
- mv vim vim.bin
- mv vim.s vim
- The drawback of this method is that when you reinstall Vim, you need to repeat the renaming.