Map Esc key in Vim

前端 未结 5 708
再見小時候
再見小時候 2020-12-31 16:47

I\'m a beginning Vim user. I hate pressing the Esc key, which is a little far on my T61. In order to return to command mode. How do I map it to F4?

相关标签:
5条回答
  • 2020-12-31 17:03

    For a single session, you could just enter the following keystrokes exactly:

    esc:imapspace<f4>space<esc>enter

    The esc key ensures that you're in command mode, colon starts a line command, and the imap maps the F4 key to ESCAPE.

    However, if you want this retained for every session, you'll need to put in in your Vim start-up file.

    The location of this varies depending on your environment (for my Linux box, it's at $HOME/.gvimrc for gvim, $HOME/.vimrc for vim). You'll need to find it and add the line:

    imap <f4> <esc>
    

    One trick you can use is to start a naked Vim session (vim without an argument) then enter

    :e $MYVIMRC
    

    which will open up your current start-up file.

    Also,

    :echo $HOME
    

    should tell you the location of it under Windows.

    0 讨论(0)
  • 2020-12-31 17:03

    Just like many Emacs users rebind their "Caps Lock" key to "Control", vimmers rebind their "Caps Lock" to "Escape".

    ...At least I do. And it works wonders.

    0 讨论(0)
  • 2020-12-31 17:07

    Another way to exit insert mode is to use Ctrl+C. Not sure whether that helps in your situation though.

    0 讨论(0)
  • 2020-12-31 17:17

    Try home row:

    imap jj <Esc>
    
    0 讨论(0)
  • 2020-12-31 17:24
    imap <F4&> <ESC>
    
    0 讨论(0)
提交回复
热议问题