Traversing text in Insert mode

后端 未结 12 1302
逝去的感伤
逝去的感伤 2020-12-02 03:00

While in Insert Mode in Vim, is there any way to traverse the text moving some characters forward and backward other than using the arrow keys?

If I

12条回答
  •  旧时难觅i
    2020-12-02 03:53

    If you are a vim purist, skip reading this answer. OTOH, if you are new to vim and are looking for a few helpful tips you wont find in the many hundred of vim tutorials and blogs, read on... :-)

    A few un-orthodox (vim) ways

    It's 2014, and as someone who's recently gone back to vim I can offer a few, potentially contrarian, points of view and tips.

    Use shift+left or shift+right to traverse words

    While repetition is a powerful concept in vim, I (personally) find it strange that using it either forces me to count (lines, characters, words, etc.) or make guesses. My brain usually works like "I want the cursor there" and not like "I want the cursor _5_words_to_the_left_". Quickly being able to move the cursor, and visually observe where the insertion point this way allows me to keep my mind on what I'm editing instead of having to count how many hops I need to make to get to where I need to edit.

    Turn on mouse mode, and use the mouse wheel and clicking

    ...to navigate large bodies of text.

    Most (all) modern computers have a touchpad that is closely integrated with the keyboard (e.g. MacBooks). Industrial designers have spent many man years optimizing these designs so that the old problem of having to move the hand away from the keyboard is no longer a real issue. Okay, it is if you are used to a mouse and don't like to switch, but for anyone new to vim (like those that might find this post via a search), this should not be much of an issue.

    As a bonus, click + drag puts you in visual mode

    With mouse enabled, clicking and dragging has the effect of switching to visual mode and marking a region for yanking.

    And use the scroll wheel

    Using the mouse (wheel) to scroll around, and clicking to position the cursor (duh) just works. See http://usevim.com/2012/05/16/mouse/ for more on this.

    And so...

    These are what I'd call more modern (using mouse, scroll wheel, etc.) ways of navigating in vim, equally effective depending on your preference of input.

    HTH

提交回复
热议问题