I have a bad habit of using the \'home\' key to go back to the beginning of a line. As I recently started using vim I noticed that when I press the home key on a lined that is i
Here’s what I have in my .vimrc
. This maps Home to move to the beginning of the
text if you are anywhere in the line, and column 0 if you are at the beginning
of the text.
function ExtendedHome()
let column = col('.')
normal! ^
if column == col('.')
normal! 0
endif
endfunction
noremap :call ExtendedHome()
inoremap :call ExtendedHome()
Note: I am using a keyboard layout that maps Home to Alt Gr+A, that why I’m using this. If you have to leave the letter field of your keyboard to reach Home, you should probably go to normal mode instead.