tom
tom

Reputation: 553

surprising behavior from vim maps to 0, $, and ^

The 0, $, and ^ keys are far from home row for how often I use them, so I thought I'd remap them to H, L, and U (respectively), like so:

nnoremap H 0     " start of line
nnoremap L $     " end of line
nnoremap U ^     " first non-blank character

But instead of doing what I'd expect, H and U put the cursor at the 6th character of a line, and L moves the cursor to the 5th or 4th character of the line below. WHat's happening, and can it be fixed?

Upvotes: 1

Views: 94

Answers (1)

FDinoff
FDinoff

Reputation: 31429

nnoremap thinks that you want to map H to 0 " start of line. It is not treating the " as the start of a comment.

You should move the comments to a different line.

" start of line
nnoremap H 0
" end of line 
nnoremap L $
" first non-blank character 
nnoremap U ^

Upvotes: 5

Related Questions