Discussion:
Using cursor keys with VIM...
Ken Morley
2006-05-17 21:05:12 UTC
Permalink
I am new to OpenBSD 3.8, but have a lot of experience with SuSE & RedHat
Linuxes.



The problem is that I've always been able to use the cursor keys when
editing with VIM under

SuSE and RedHat and I can't seem to break the habit. So, I keep
trashing the file I'm working on

by using the control keys.



I currently use VanDyke's Secure-CRT 5.0 terminal emulation software.
No matter how I configure

OpenBSD or the terminal emulation software, I can't find a combination
that will correct the problem.



If you have a suggestion other than removing those keys from the
keyboard, I would love to hear it.



Thanks very much!



Ken Morley
Spruell, Darren-Perot
2006-05-17 22:11:16 UTC
Permalink
Post by Ken Morley
The problem is that I've always been able to use the cursor keys when
editing with VIM under
SuSE and RedHat and I can't seem to break the habit. So, I keep
trashing the file I'm working on
by using the control keys.
I currently use VanDyke's Secure-CRT 5.0 terminal emulation software.
No matter how I configure
OpenBSD or the terminal emulation software, I can't find a combination
that will correct the problem.
If you have a suggestion other than removing those keys from the
keyboard, I would love to hear it.
You could learn vi(m) navigation the *right* way and move your cursor with
h,j,k,l.

The vimtutor app is quite helpful.

:wq

DS
Stuart Henderson
2006-05-17 22:38:05 UTC
Permalink
Post by Spruell, Darren-Perot
Post by Ken Morley
The problem is that I've always been able to use the cursor keys when
editing with VIM under SuSE and RedHat and I can't seem to break the habit.
I currently use VanDyke's Secure-CRT 5.0 terminal emulation software.
Try xterm emulation (and set TERM to xterm or xterm-color). If you
can't get SecureCRT playing nicely, try PuTTY (or switch desktop OS)[1].
Post by Spruell, Darren-Perot
You could learn vi(m) navigation the *right* way and move your cursor with
h,j,k,l.
this is really not fun if you use a Dvorak keymap...



[1] Actually, if you want to switch desktop OS, don't try PuTTY because
it will only delay the inevitable and encourages you to endure Windows for
longer.
Ted Unangst
2006-05-17 22:21:42 UTC
Permalink
Post by Ken Morley
The problem is that I've always been able to use the cursor keys when
editing with VIM under
SuSE and RedHat and I can't seem to break the habit. So, I keep
trashing the file I'm working on
by using the control keys.
I currently use VanDyke's Secure-CRT 5.0 terminal emulation software.
No matter how I configure
OpenBSD or the terminal emulation software, I can't find a combination
that will correct the problem.
use a decent .vimrc. most people's complaints about vim (whether "it
does too much" or "it does too little") all come from not having or
not knowing what's in .vimrc. you're probably in need of "set
nocompatible" at a minimum.
Sam Chill
2006-05-18 00:49:53 UTC
Permalink
Post by Ken Morley
I am new to OpenBSD 3.8, but have a lot of experience with SuSE & RedHat
Linuxes.
Welcome!
Post by Ken Morley
The problem is that I've always been able to use the cursor keys when
editing with VIM under
SuSE and RedHat and I can't seem to break the habit. So, I keep
trashing the file I'm working on by using the control keys.
The first thing I do on my OpenBSD boxes after installing vim is to cd
/usr/local/share/vim/vim?? (where ?? correspondes to the version of
vim you are running for me it is 70 but for you it will probably be 6
something) and I copy the file vimrc_example.vim to ../vimrc
(/usr/local/share/vim/vimrc) and edit it as I see fit. It provides
some sane defaults and makes vim very usable for me. The other option
would be to copy it to ~/.vimrc.
Post by Ken Morley
Thanks very much!
You're welcome!
Post by Ken Morley
Ken Morley
Sam Chill
Jeff Quast
2006-05-18 12:29:50 UTC
Permalink
Post by Ken Morley
I am new to OpenBSD 3.8, but have a lot of experience with SuSE & RedHat
Linuxes.
The problem is that I've always been able to use the cursor keys when
editing with VIM under
SuSE and RedHat and I can't seem to break the habit. So, I keep
trashing the file I'm working on
by using the control keys.
(function keys)
Post by Ken Morley
I currently use VanDyke's Secure-CRT 5.0 terminal emulation software.
No matter how I configure
Try using putty. save yourself a registration fee and support open
source software.
Post by Ken Morley
OpenBSD or the terminal emulation software, I can't find a combination
that will correct the problem.
try TERM=xterm or its variants
Post by Ken Morley
If you have a suggestion other than removing those keys from the
keyboard, I would love to hear it.
Thanks very much!
Ken Morley
From the OpenBSD console, I have seen that it generates different ansi
sequences than what is -typical- in xterm etc. I can't complain, 'ansi
sequences' are misleading, in that ansi sequences were never
standardized, though the name implies it.

vim does it's best to define sequences depending on your TERM. However
this doesnt map correctly to an OpenBSD console with TERM=vt220 or
TERM=wsvt25. I've found the need for these in my vimrc:

if $HOSTTYPE=="OpenBSD"
" OpenBSD function keys
set t_k1=[11~ " f1 through ..
set t_k2=[12~
set t_k3=[13~
set t_k4=[14~
set t_k5=[15~
set t_k6=[17~
set t_k7=[18~
set t_k8=[19~
set t_k9=[20~
set t_k;=[21~
set t_F1=[23~
set t_F2=[24~ " ...f12
set t_kP=[5~ " page up
set t_kN=[6~ " page down
set t_kh=[7~ " home
set ***@7=[8~ " end
endif

Simply look up the :help section that lists all of the key code
variables and re-configure them. For F1, simply into a .vimrc:

set t_k1=<esc><ctrl+v><F1>

and so on...

Do this from SecureCRT and they keys will work correctly.

As somebody else pointed out, try using hjkl and vimtutor. You'll
thank yourself later. Some people say vi is only for hardcore hackers
who like to overcomplicate something as simple as an editor, but I
feel it allows me to be so lazy that I barely have to move my hands
around, esp wen using ^[ instead of the escape key.

jdq

Continue reading on narkive:
Loading...