Vim moving cursor to the beginning of the next line
Solution 1
The +
motion moves to the first non-blank character in the next ([count]
) line. That fulfills your requirement if there's no indent. With indent, you can use +0
or j0
.
Solution 2
You can move to the beginning of a line by pressing +
That just moves to the first non-blank character at the beginning of the line, which is fine if there is no indentation. If you want to go to the first character in the line regardless of white space, you can do j0
If you need any more help with movement keys, this is a good resource: http://vim.wikia.com/wiki/Moving_around
Lavya
Updated on December 23, 2021Comments
-
Lavya over 2 years
In Vim, is there a key moving cursor to the beginning of the next line?
j
moves the cursor to the corresponding position of the current position in the next line. I'm looking for a single key that could move the cursor to position 0 irrespective of the cursor position in the current line. -
Ingo Karkat over 9 yearsWhy do you revise your answer to just match mine?!
-
EvergreenTree over 9 years@IngoKarkat Sorry about that. I didn't realize that the question was "go to beginning of next line" when I first answered, and I changed it to something that actually answered the question. I can delete this if you want.
-
Ingo Karkat over 9 yearsThat's fine. Your answer still has the useful link, so just keep it.
-
Peter Rincker over 9 years
<cr>
and+
are the same motion but way more convenient. This motion is great when recording macros -
Lavya over 9 years@PeterRincker Thanks. Do you know if vim allows the same functionality with respect to screen lines as opposed to text lines? I was hoping that g+ would do that, just like gj takes you down one screen line, g$ to the end of the screen line and so on, but in this case it (g+) seems to have some other functionality..
-
Lavya over 9 years@EvergreenTree Thanks! Do you know if the same is achievable with respect to the screen lines?
-
Peter Rincker over 9 years@Lavya In theory you an use
gj
andg^
together to create a "g<cr>
" mapping however I do not thinkg^
behaves quite how I expected it to. See:h g^
. e.g.nnoremap g<cr> gjg^
. Theg+
andg-
are undo navigation commands and can be quite helpful. I would suggest against overriding them. See:h g+
and:h undo-tree
for more information. The undo tree is pretty cool especially when paired with persistent undo (See:h persistent-undo
). -
EvergreenTree over 9 years
gjg0
should do the trick, asgj
moves down one display line andg0
goes to the first character in the display line. It might be a good idea to create a mapping for it if you use it a lot. -
winklerrr about 7 years
+
and+0
doesn't work with sublime.j0
worked for me.