开发者

Vim navigation clunkiness

开发者 https://www.devze.com 2023-02-02 12:45 出处:网络
I\'ve committed myself to diving into vim to become faster at writing code for ruby/python and I\'m having a hard time navigating around files.

I've committed myself to diving into vim to become faster at writing code for ruby/python and I'm having a hard time navigating around files.

Mainly, I'm referring to switching between insert mode and navigation modes. Maybe I'm just not completely used to the editor yet but it feels very awkward to constantly be switching in and out of insert mode.

Is this something that will go away with time? Are there any tricks to get开发者_运维知识库ting quicker at moving in and out of insert mode?


Read the "Misconception #1" part of this excellent article: http://www.viemu.com/a-why-vi-vim.html


Many people like to define jj or jk as something to type while in insert mode to go back to normal mode (rather than hitting escape), this keeps your hands on the home row and speeds things up. You can put this in your .vimrc to do this mappings (or just choose one of them):

inoremap jj <ESC>
inoremap jk <ESC>

If you really need to type either of these strings (super rare for me), you can just type the first letter and pause for a couple of seconds, then type the 2nd one.

I also find that really understanding all of the movement keys while in normal mode helps to understand the power of movement within vim and how it gets you to the place you want to go more quickly (thus offsetting and beating the overhead of having to go into/leave insert mode).

To this end, I threw together a vim movement wallpaper dedicated to visually showing the various movement commands relative to the current cursor position (the center of the screen). Having this up, helped me commit them to memory and made me much quicker.

Additionally, understanding the various basic insert keys, helps you get into insert mode in the right place:

  • i - insert before the letter the cursor is on
  • a - append after the letter the cursor is on
  • I - insert at the beginning of the current line
  • A - append at the end of the current line
  • o - open up a new line below the current line
  • O - open up a new line above the current line

Also learning/understanding the various delete, change, substitution and find/replace regexp commands should probably come next.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号