Vim: move around quickly inside of long line

后端 未结 8 563
轻奢々
轻奢々 2020-12-22 18:50

I have word-wrap enabled and tend to have quite long lines. But moving around inside a line that\'s actually 4 lines high with \"w\" is cumbersome. I keep using / to jump to

相关标签:
8条回答
  • 2020-12-22 19:35

    If you choose to go the route of remapping these:

    nnoremap k gk
    nnoremap j gj
    

    here are a couple others along the same lines:

    nnoremap 0 g0
    nnoremap $ g$
    nnoremap ^ g^
    
    0 讨论(0)
  • 2020-12-22 19:42
    • You can use $, 0, and ^ to move to line endpoints and then use w and b. Also, adding a numeric argument to w and b can accelerate the process, so using 6w instead of just w can put you about to where ou need to be.
    • Using f and t to move to individual characters will help also. (I use this typically with punctuation. If, for example, I have four sentences on one long line 2f. will go to the end of the second sentence)
    • Using the ( and ) keys are an alternative way to navigate entire sentences.
    • Splitting out long lines into multiple lines (manually, or with set tw=72 [or 80]) can make editing them simpler. You can always join them later with J.
    • Something I just discovered, you can move up and down one displayed line by using gj and gk. That way, you can treat your one wrapped line as multiple lines.

    If you comment on the type of data you're editing, it might make it easier for us to make suggestions.

    0 讨论(0)
提交回复
热议问题