DEV Community

Jonas Schumacher
Jonas Schumacher

Posted on

Vim: Jump to first non-whitespace character in line

Press ...

^

Yes, that's it.

Top comments (2)

Collapse
 
pbnj profile image
Peter Benjamin (they/them) • Edited

For bash users who are used to ctrl+a and ctrl+e, it may be convenient to have the same shortcuts in vim:

" normal mode
nnoremap <c-a> ^
nnoremap <c-e> $
" visual mode
vnoremap <c-a> ^
vnoremap <c-e> $
" insert mode
inoremap <c-a> <esc>^i
inoremap <c-e> <esc>$a
" commandline mode
cnoremap <c-a> <c-b> " this is specially useful in tmux since <c-b> is the default tmux prefix/mod key, which requires users to type <c-b> twice to move the cursor to the beginning of the line in vim commandline mode
" cnoremap <c-e> <c-e> " this is not needed since <c-e> is the default vim keybinding for moving cursor to end of line in commandline mode
Enter fullscreen mode Exit fullscreen mode
Collapse
 
kadena_az profile image
k:soonsoon

Can you help create some code that will allow quotes to be stored in a folder for use in notes without the requirement of having them exist in the root directory? Thanks