Improved VIM experience: Move the cursor in insert mode, I don't want to use the arrow keys! Alt shortcut key use Tips!

Source: Internet
Author: User

Improved VIM experience: Move the cursor in insert mode, I don't want to use the arrow keys! Alt shortcut key use Tips!

As we all know, when we edit the code in insert mode,

If you want to finish this part, moving to a neighboring part, following a word, is very complicated.

' \eea ' or ' directional key *n '? Although this is not complicated, especially referring to my previous document, \e (ESC) only need to press alt-;

But is there a more convenient way? I'm going to tell you, there is, Alt accelerator remapping in insert mode!

Set the key code as follows

, set the key code to determine the time, this time and the combination of key judgment time is different yo! Only need to set once: Set Ttimeout ttimeoutlen=50; set keys <M-e> key combination to \ee;\e for ESC:exec"  set <m-e>=\ee"; remap <M-e> for <esc><M-e> <esc> Ea

This allows you to use ALT-E in insert mode to complete the operation after moving the cursor to the next word! It's Convenient!

Insert the following paragraph into the ~/.VIMRC, you can use the alt-w\w\e\e\h\j\k\l these shortcut keys

Inoremap <M-j> <esc>jaexec "Set <m-j>=\ej"Inoremap<M-k> <esc>kaexec "Set <m-k>=\ek"Inoremap<M-h> <esc>haexec "Set <m-h>=\eh"Inoremap<M-l> <esc>Laexec "Set <m-l>=\el"Inoremap<M-W> <esc>Wiexec "Set <m-w>=\ew"Inoremap<M-w> <esc>WIexec "Set <m-w>=\ew"Inoremap<M-E> <esc>Eaexec "Set <m-e>=\ee"Inoremap<M-e> <esc>EAexec "Set <m-e>=\ee"Set Ttimeout Ttimeoutlen=100


According to this principle, all kinds of shortcuts in various modes are set up the same way

Reference: How to correctly use Alt mapping in VIM

Improved VIM experience: Move the cursor in insert mode, I don't want to use the arrow keys! Alt shortcut key use Tips!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.