DEV Community

Tom Harada
Tom Harada

Posted on • Edited on

vim shortcuts that i find central

This is my first post. I always wanted to write a blog post about the vim key-mappings and general approaches that I use that I've found super useful over the years. I tend to make them work wherever there is vim or vim-emulation (Vimium / Chrome, VSVim / VS Code, IdeaVim / IntelliJ, XVim2 / Xcode, tmux integration, Codepen, etc.).

Till I Die:

ctrl-hjkl -> ctrl-w hjkl with tmux integration
gd -> go to definition (e.g., using ALE; i haven't cleaned this up for all languages)
ctrl-o -> jump back
ctrl-i -> jump forward
. -> repeat command
qa...q -> macros
<format on save (e.g., using prettier, black)>
Enter fullscreen mode Exit fullscreen mode

Til the Sun Dies:

fd -> escape
[In System Preferences, map] caps lock -> control
; -> :
Enter fullscreen mode Exit fullscreen mode

Top comments (4)

Collapse
 
moopet profile image
Ben Sinclair

Oh i see you have a shortcut to run python for the buffer:

nnoremap fp :VimuxRunCommand "python3 ".expand("%:p")<cr>

I have this one:

autocmd FileType python nnoremap <f5> :execute '!ipdb3 -c "break ' .line(".") . '" -c "continue" %'<cr>

That runs the script with ipdb instead with a breakpoint set at the current line. I chose F5 because it's a common "Run/Debug" shortcut in IDEs.

Collapse
 
p10q profile image
Tom Harada

Good to know! Nice. I’ll try experimenting with that.

Collapse
 
moopet profile image
Ben Sinclair

I'm one of those people who actually uses ; :P

Collapse
 
p10q profile image
Tom Harada

Interesting! TIL about its default behavior. Does seem handy.

(I guess I’m used to just having hjkl move for motion with max repeat speed. But f seems more elegant if your neurons are trained that way :) )