How to exchange 0 and ^ behaviour in vim

Viewed 46

I don't know why after this

" Exchange 0 and ^
noremap 0 ^
noremap ^ 0

they both have the same behaviour as ^.

Same with

" Exchange $ and _
noremap $ _
noremap _ $

$ goes to the new line character before having this. But after that both $ and _ go to the last character and I don't have a way to go the new line character.

How do I make ^ go to the beginning of the line including whitespace and 0 go to the first non-whitespace character in the line? Maybe this is fine and some plugin is changing it's behaviour. Does it work fine for you?

1 Answers

You could do something like:

noremap 0 g^
noremap ^ <Home>

You just have to make sure they do not depend on each other.

Related