dsaxton
dsaxton

Reputation: 1015

Move to first character in line above in vi

When using vi in normal mode I've noticed that the enter key will bring the cursor to the first character of the line directly below. This is a nice feature but I can't seem to find the key for doing the same thing upwards. Anyone know either of a key that does this or how to create my own?

Upvotes: 1

Views: 1973

Answers (1)

FDinoff
FDinoff

Reputation: 31429

- (minus) goes to the first non black character on a line going upwards.

One way to figure this out is by looking at the help for <CR> here you find

+               or                                      *+*
CTRL-M          or                                      *CTRL-M* *<CR>*
<CR>                    [count] lines downward, on the first non-blank
                        character |linewise|.

Which tells you that +, <C-M> and <CR> are equivalent. If you look at the section about this you would see

                                                        *-*
-  <minus>              [count] lines upward, on the first non-blank
                        character |linewise|.

which is what you were looking for.

Upvotes: 6

Related Questions