I'm pretty new to vimscript, and I wrote this little function to map
H so that the cursor will go to the first non-whitespace character of the line, or to the beginning of the line if the cursor is already at the first non-whitespace character. I just want to a) share this for anyone who might find this useful, and b) ask if there's a more efficient way to do this. I feel like there should be some more in-built way to do this.
function! HFunc() let colnum1 = col(".") execute "normal! ^" let colnum2 = col(".") if(colnum1 == colnum2) execute "normal! ^0" endif endfunction nnoremap <silent>H :call HFunc()<cr>