Moving by line and not by sentence
Using macvim. Say I have one sentence which takes up 5 lines in the editor. And a second sentence which occupies th开发者_如何学编程e 5 next lines. Start with cursor on line 1. In normal mode, pressing j
will take me to the next sentence (that is, line 6).
How to change this behavior to where pressing j
will take me to line 2 (which is still part of the first sentence?). Or instead of using j
, any other way to achieve this goal?
The actual problem is that the line (not sentence) is too long and it wraps to multiple display lines. The default movement with j
and k
will move the cursor in real lines, not display lines.
You can remap j
and k
in normal mode to do move in display lines:
nnoremap j gj
nnoremap k gk
(in your .vimrc).
j
takes you to the next line. I think you have a terminology problem (“sentence” doesn't mean what you seem to think it means). If j
doesn't take you to the next line on the screen, it's because the file contains a very long line (what you call a “sentence”) that is too wide to fit on the screen. If there is a very long line, it is displayed on several screen lines. Vim calls these “display lines”. The j
command moves to the same position on the next file line; gj
moves to the same column on the next screen line.
精彩评论