Wrap end-of-line code vim

One of the big troubles when using vim in a mac keyboard is the lack of Home and End keys. Although there is work in vim, namely

$ for End of line 0 for Beginning of line (both in <Esc> mode) 

I find it unintuitive because $ is on the left side of the keyboard and takes you to the far right side of the text, while 0 is on the right side, you get to the beginning of the line. Is there a way to reassign keys with 9 for the beginning of the line and 0 for the end of the line?

I tried the following in my ~ / .vimrc

 inoremap <Esc>9 <Esc>0 inoremap <Esc>0 <Esc>$ 

but it does not seem to take effect, and the old key combinations are still in place. Help me out! Also let me know about the disadvantages of this (if any)? Thank you

+4
source share
1 answer

inoremap is for insert mode matching. What you are looking for is nnoremap . For example, you can try the following:

 nnoremap 0 $ nnoremap 9 0 inoremap <CA> <Home> inoremap <CE> <End> 

However, I personally would not have remade 9, as you may need it someday (for example 9gg or 9j ). Instead, I would go for Q , K , U or S , since they are hardly used.

In fact, I would probably recommend leaving it as it is. $ is actually pretty intuitive when you learn about regular expressions. It's a bit complicated, but overall you won't need it because you have a lot of commands, such as D , that map to d$ . And it will also be easier when you have to work with vanilla vim.

+18
source

All Articles