-   Linux - Software (
-   -   VI problem, never been solved (

phoeniXflame 07-27-2003 03:09 PM

VI problem, never been solved
vi behaves very oddly on all my systems, I dont understand it, I'm using fluxbox and xterm to access it, but when I'm in insert mode the arrow keys just seem to insert letters :( and also when I press 'i' to goto insert mode ... it dosnt say 'INSERT' in the bottom right hand corner, does anyone have ANY ideas, please, I've started this thread like 3 times over the last few month, but no-ones ever had the answer :(

atm I'm having to use pico locally, and I hate it ! please help me !

megaspaz 07-27-2003 04:06 PM

wierd. are the keys being inserted escape keys? wierd since linux is supposed have that set up for ya already. anyway try this out.


vi and Cursor-Keys

Vi uses the esc-key as a command to exit insert mode. Unfortunately for most terminals the arrow-keys send an an escape sequence (starting with the ESC character) to the host. Vi must distinguish between these two meanings of ESC. A smart vi (such as vim if configured for it) is able to detect the difference by noting the time between the ESC and the next key. If it's a short time, then it's likely that a cursor key was pressed. Use "help cursor-keys" in vim to find out more.

Here's another way to fix this. On VT terminals the left-arrow-key may be either set to send ESC [ D or ESC O D. The other arrow keys are similar but use A, B, and C instead of D. If you're having problems, choose ESC [ D since the "O" in the other alternative could be interpreted by vi as a command to "Open a line". The "[" should be interpreted by vi to mean that an arrow-key has been pressed. ESC [ D will be sent provided "Cursor Key Application Mode" has not been set. ESC [ D is normally the default so everything is seemingly OK. Except that many termcaps contain a string (not the init string) which sets what you want to avoid: "Application Mode". Editors may send this string to the terminal when the editor starts up. Now you are in trouble.

This string has the termcap code "ks" (smkx in terminfo) meaning enable the function (and related) keys (including the arrow keys). An application enables these keys by sending the "ks" string to the terminal. Whoever wrote the termcap reasoned that if an application wants to enable these keys, then they should be put into "Application Key Mode" since this is an "application", but you don't want this.

The Linux console has no "ks" string so you can't fall into this trap at the console. For other terminals you may need to edit the termcap (or terminfo) or use another termcap entry. You need to change not only the "ks" string but also the termcap definitions of what they send: kd, kl, kr, ku. Then run tic to install it.

For vim (vi iMproved) there is a way to set it up to work OK with ESC O D (so you don't need to edit termcap): See vim help for "vt100-cursor-keys". You may run "gitkeys" and then press your cursor keys to see what they send but they may be set to send something different when you're in an editor.

phoeniXflame 07-27-2003 04:41 PM

well, sorry, after closer inspection I've actually found I was using a symlink to a vim binary, but this dosnt actually bring me any closer to a solution, I just find it very odd when even pressing the i key to goto insert mode dosnt bring up the word INSERT in the bottom right hand corner, yet it still is in insert mode because I can insert text :( its so weird :(

lfur 07-27-2003 04:59 PM


can you use vim normally outside X?? An have you tried gvim in X (it's part of the xvim package)?

phoeniXflame 07-27-2003 05:02 PM

yea that seems to be ok, but I want to use it from xterm really :|

lfur 07-27-2003 05:32 PM

Have you checked your .vimrc?

phoeniXflame 07-27-2003 05:37 PM

dont seem have one

lfur 07-27-2003 06:03 PM

Hehe, well it seems that is your problem. It happened to me once, and vim was acting as weird as your is. Then I found out, that i had accidentally typed:
> .vimrc

instead of:
> .gvimrc

You can use this one if you like:

" An example for a vimrc file.
" Maintainer:        Bram Moolenaar <>
" Last change:        2002 May 28
" To use it, copy it to
"    for Unix and OS/2:  ~/.vimrc
"              for Amiga:  s:.vimrc
"  for MS-DOS and Win32:  $VIM\_vimrc
"            for OpenVMS:  sys$login:.vimrc

" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"

" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible

" allow backspacing over everything in insert mode
set backspace=indent,eol,start

set autoindent                " always set autoindenting on
" =================================================================
"if has("vms")
"  set nobackup                " do not keep a backup file, use versions instead
"  set backup                " keep a backup file
"  endif
" =================================================================
set nobackup        " don't keep a backup file
set history=50                " keep 50 lines of command line history
set ruler                " show the cursor position all the time
set showcmd                " display incomplete commands
set incsearch                " do incremental searching
set tabstop=8                " keeping tab at default level
set softtabstop=2        " using softtab to set user level
set shiftwidth=2        " avoid 8 character auto indent
set noexpandtab        " no auto expanding - see lines 38 - 40
" set number                " uncomment this for line numbering

" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")

" Don't use Ex mode, use Q for formatting
map Q gq

" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp

" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
  syntax on
  set hlsearch

" Only do this part when compiled with support for autocommands.
if has("autocmd")

  " Enable file type detection.
  " Use the default filetype settings, so that mail gets 'tw' set to 72,
  " 'cindent' is on in C files, etc.
  " Also load indent files, to automatically do language-dependent indenting.
  filetype plugin indent on

  " For all text files set 'textwidth' to 78 characters.
  autocmd FileType text setlocal textwidth=78

  " When editing a file, always jump to the last known cursor position.
  " Don't do it when the position is invalid or when inside an event handler
  " (happens when dropping a file on gvim).
  autocmd BufReadPost *
    \ if line("'\"") > 0 && line("'\"") <= line("$") |
    \  exe "normal g`\"" |
    \ endif

endif " has("autocmd")

And please let me know if it solves the problem.


phoeniXflame 07-28-2003 04:44 AM

omg I could kiss you I really could ! that solved it ! :D everything is working perfectly now ! yay ! no more pico :D

thankyou VERY much

lfur 07-28-2003 06:19 AM

Hehe, what a reaction! :)

Glad I could help.


phoeniXflame 07-28-2003 06:39 AM


Originally posted by lfur
Hehe, what a reaction! :)

Glad I could help.


heh, well its because its taken SOO long to work out why its happening :)

All times are GMT -5. The time now is 12:52 AM.