Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3757646
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T10:02:21+00:00 2026-05-19T10:02:21+00:00

In my .vimrc file I have the line inoremap jj << Esc>> (I can’t

  • 0

In my .vimrc file I have the line

inoremap jj << Esc>> 

(I can’t live without this :))

I wish to have the same remap while using ksh in set -o vi mode, any advice on how to do this is appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-19T10:02:21+00:00Added an answer on May 19, 2026 at 10:02 am

    Give this a try:

    _key_handler () {
        # by Dennis Williamson - 2011-01-14
        # for http://stackoverflow.com/questions/4690695/remapping-keys-for-ksh-vi-mode
        # 2011-01-15 - added cursor color change
    
        typeset timeout=1    # whole seconds
    
        # the cursor color change sequences are for xterms that support this feature
        if [[ $TERM == *xterm*color* ]]
        then
            typeset color=true   # change cursor color when chars are held
            # cursor colors - set them as you like
            typeset nohold="\E]12;green\a" hold="\E]12;red\a"
        else
            typeset color=false
        fi
    
        if [[ ${.sh.edmode} == $'\x1b' ]]    # vi edit mode
        then
            case ${.sh.edchar} in
                j)
                    if [[ $_kh_prevchar == j ]]
                    then
                        if (( $SECONDS < _kh_prevtime + timeout ))
                        then
                            .sh.edchar=$'\E'    # remapped sequence
                            _kh_prevchar=''
                            $color && printf "$nohold"
                        fi
                    else
                        _kh_prevchar=${.sh.edchar}
                        .sh.edchar=''
                        $color && printf "$hold" &&
                          # jiggle the cursor so the color change shows
                          tput cuf1 && sleep .02 && tput cub1
                    fi
                    _kh_prevtime=$SECONDS
                    ;;
                *)
                    if [[ -n $_kh_prevchar ]]
                    then
                        .sh.edchar=$_kh_prevchar${.sh.edchar}
                    fi
                    _kh_prevchar=''
                    $color && printf "$nohold"
                    ;;
            esac
        fi
    }
    trap _key_handler KEYBD
    set -o vi
    

    Put it in a file, ~/.input.ksh for example, and source it from your ~/.kshrc or similar.

    Pressing “j” will put it on hold. If the time runs out before pressing another “j”, the first “j” will be output and the next one will be held. If another key besides “j” is pressed, the held “j” and the next character are output together. If a second “j” is pressed before time runs out, the remapped sequence will be output.

    Example: Pressing “j”, pause, then press “jj” will yield no response at first then “j<< Esc>>” all at once.

    A difference between this and vim is that vim will go ahead and output the held character after the time runs out even if another key hasn’t been pressed yet. Also, the timeout in this is in whole seconds, while in vim it’s in milliseconds.

    I’ve only tested this a little and only with ksh93.

    Edit: Added cursor color change.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my .vimrc file, I have this line: set mouse=a This enables the mouse
I have a .vimrc file that contains the following line: syntax match proper /\s[A-Z][a-zA-Z]*/
I have this in my .vimrc set formatprg=astyle I can press gggqG to format
I have a line set cpoptions+=$ in my .vimrc file. However according to verbose
after months of tweaking my vimrc file and installing plugins, I have this little
I downloaded this vimrc file. It contains entries for mapping comma seperated keys to
I want to edit .vimrc file from Vim and apply them without restarting Vim.
In my .vimrc file, how can I make it so that when I tab
I tote the same .vimrc between machines that have both Vim 7.2 and 7.3
In my .vimrc file, I have the following function, which folds the licensing information

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.