简体   繁体   中英

Make up down left right keys work in KornShell (ksh) Command line

Any update you can provide will be great.

When I put this in .profile:

set -o emacs 
alias __A=`echo "\020"`     # up arrow = ^p = back a command 
alias __B=`echo "\016"`     # down arrow = ^n = down a command 
alias __C=`echo "\006"`     # right arrow = ^f = forward a character 
alias __D=`echo "\002"`     # left arrow = ^b = back a character 
alias __H=`echo "\001"`     # home = ^a = start of line 
alias __Y=`echo "\005"`     # end = ^e = end of line 

I can use the up/down keys for history.

But I want to edit from the command prompt using vi commands. I know set -o vi will do that, but then I lose the up/down key functionality provided by set -o emacs .

Bottom line is: I want to use the up/down/left/right arrow keys and I want to edit from the command prompt using vi commands. How to do this?

Use a .vimrc dotfile to disable the bindings to special keys, then map each arrow motion from the default vi keys to the cursor keys in normal mode using angle bracket notation :

set cpo-=<
set exrc
set fileformats=unix,dos,mac
nmap k <Up>
nmap j <Down>
nmap h <Left>
nmap l <Right>

References

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM