• Home
  • Shell
    • Emacs
    • Perl
    • screen
    • sed
  • Ubuntu
    • VNC
  • Web Development
    • Javascript
    • Joomla
    • MySQL
    • osTicket
  • Windows
    • Gimp

Posts tagged arrow

BASH> Fix vi arrow keys in insert mode

Mar28
2013
Written by Scott Rowley

Full credit to Michael S. Kirkpatrick

The following fix saved my sanity

I prefer using vi as my text editor, because it is clean and simple. I don’t have to go searching for commands from drop-down boxes and other GUI crap. But arrow keys and backspace are sometimes problematic, depending on the OS you’re using. In my case, I frequently ssh from Linux to SunOS, and the SunOS vi doesn’t like my keyboard mappings.

Here is my (partial) solution. Open ~/.exrc and add the following lines. In case it is not obvious, do not type the letters inside brackets, but press those keys instead (i.e., [ctrl-v] means you hold the Ctrl key while pressing v).

— Michael S. Kirkpatrick

:map! [ctrl-v][backspace] [ctrl-v][esc]xa
:map! [ctrl-v][up-arrow] [ctrl-v][esc]ka
:map! [ctrl-v][down-arrow] [ctrl-v][esc]ja
:map! [ctrl-v][right-arrow] [ctrl-v][esc]la
:map! [ctrl-v][left-arrow] [ctrl-v][esc]ha

When you type these in (assuming you’re using vi or vim, these lines will look like this.

:map! ^? ^[xa
:map! ^[OA ^[ka
:map! ^[OB ^[ja
:map! ^[OC ^[ha
:map! ^[OD ^[la
Posted in BASH - Tagged backspace, control, ctrl, down, editor, esc, escape, exrc, fix, key, keys, left, map, Michael S. Kirkpatrick, right, up, vi, vim

Corrections? Questions? Comments?

Find an error?
Everything work out great for you?
Have some feedback?
Like to see something added to the article?

PLEASE leave us a comment after the article and let us know how we are doing, or if something needs corrected, improved or clarified.

Thank you!
- The Management

Advertisement

Sudo Bash
By Geeks - For Geeks

Back to Top