Using number pad in VI or Vim
PROBLEM DESCRIPTION
This article explains how you can configure Xshell and terminal to allow entering numbers using the number pad in the vi or vim editor.
RESOLUTION
This problem occurs when the terminal type is not set to 'vt220' or 'ansi'. To use the color feature such as the syntax highlighting feature in vi, change the terminal type to ansi.
To change the terminal type from terminal, enter one of the following commands:
$export TERM=ansi or $setenv TERM ansi
Alternatively, you can set the terminal type in Xshell session properties. Selected terminal type will be used every time you open the session. To change the terminal type in Xshell:
- Open the Session Properties dialog box.
- Click on the 'Terminal' menu.
- From the Terminal Type list, select or type 'ansi'.
- Click OK to save the changes.
ADDITIONAL INFORMATION
If you want to set the terminal type for the vi editor only, you can create a script and execute it when you open vi. To do this:
First, create a script file in home directory with the following command:
$ vi $HOME/vi
Then, save the following lines:
#!/bin/sh TERM=ansi export TERM exec /usr/bin/vi $@
Change the permission on the file to 755:
$chmod 755 $HOME/vi
Lastly, open the login script file such as .profile, .cshrc or .login and add the following line:
$alias vi='$HOME/vi'
(If you are using C Shell, use $alias vi '$HOME/vi')
Or you can use a little code using alias.
$ alias vi=`OLDTERM=${TERM}; TERM=ansi; \vi; TERM=${OLDTERM}'