Handy Keymaps in Vim
aonemd.github.io
aonemd.github.io
""" KANBAN BOARD
" Close board tab
map <leader>bc :tabclose<CR>
" Main board: soon, doing, today, done
map <leader>bb :tabnew /media/datanix/code/mdwiki/wiki/kanban/soon.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/doing.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/today.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/done.md<CR>
" Full board: triage, later, soon, doing, today, done, archive
map <leader>bf :tabnew /media/datanix/code/mdwiki/wiki/kanban/triage.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/later.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/soon.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/doing.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/today.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/done.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/archive.md<CR>
" Triage board: triage, later, soon, doing
map <leader>bt :tabnew /media/datanix/code/mdwiki/wiki/kanban/triage.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/later.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/soon.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/doing.md<CR>
" Archiving board: done, archive
map <leader>ba :tabnew /media/datanix/code/mdwiki/wiki/kanban/done.md<CR>:vnew /media/datanix/code/mdwiki/wiki/kanban/archive.md<CR>
By no means am I a vimscript expert so any improvements welcome. (I've defined g:settings.kanban_board_path above).
function! g:Kanban_file(stage)
return g:settings.kanban_board_path . a:stage
endfunction
let $KBsoon=g:Kanban_file('soon.md')
let $KBdoing=g:Kanban_file('doing.md')
let $KBtoday=g:Kanban_file('today.md')
let $KBdone=g:Kanban_file('done.md')
let $KBarchive=g:Kanban_file('archive.md')
" Close board tab
map <leader>bc :tabclose<CR>
" Main board: soon, doing, today, done
map <leader>bb :tabnew $KBsoon<CR>:vnew $KBdoing<CR>:vnew $KBtoday<CR>:vnew $KBdone<CR>
...Although the mapping was prompted by Vim usage, it's surprisingly useful for general computing as well.
On Windows, I use the Uncap [ https://github.com/susam/uncap ] tool because it does not require install or restart. The tool has good documentation to map CapsLock to Escape for Linux and MacOS too.
On the flip side, I struggle to use Vim when I need to do so someone else's computer. :-D
noremap! kj <esc>
https://github.com/patrickdavey/dotfiles/blob/058950c2f470a1...
Jk for the win!!! (Also jj works well to).
I also set my mapleader to <Space> you would be surprised how useful that is. Not to mention , (comma) is a valid and useful vi movement key.
I have literally never found myself needing to pause to wait for a k and then a j. What are these words with "kj" in them that you're wary of? I'm genuinely curious :)
However my vim set up maps jk, kj, jj, and kk to Esc to in reality it is safe to just mash those two keys and one of the maps will work.
I had a tool on a mac that would make caps lock equivalent to escape if it was pressed and released alone, and control if it was chorded. Sounded great on paper but I underestimated how often i press control before realizing I don't want to perform a chord.
https://pqrs.org/osx/karabiner/
The equivalent for Windows would probably be AutoHotkey
Of course Karabiner can do quite a bit more than that. But if you can't or don't want to install more software it's a choice available to you.
xcape -e 'Caps_Lock=Escape;Control_L=Escape;Control_R=Escape'I don't know how many thousand key presses I've saved by not having to hit "Shift" for every command.
" Use ; rather than : for commands
nore ; :
nore , ;It simply allows you to use Ctrl+{h,j,k,l} to navigate across Vim and Tmux splits as if they all were part of one cohesive IDE. Additionally, it spares you from having to maintain a configuration blob in your .vimrc thanks to being bundled as a plugin.
I don’t think it auto-creates splits, though.
If it's indeed the case (I might well be off the mark), I can think of a few possible reasons, Maybe because VS Code has won. It is much easier for beginners than Vim/Emacs (duh) but still powerful, so less questions and issues are raised. Its default setup is very good so customization is minimum, its plugins system are both vast and easy to use, etc.
Or, Vim itself has become easier to operate since version 8, tutorials are better than before, plugins are better,
Or on HN people these days have much more interests in talking about other topics. What do you think?
However if I'm looking for something or doing something in another split and I need to view a file or edit a file I don't go back to my vim split and open it there I just open vim right there where I am.
Regarding your second point, I behave similarly. If I am off in one of my non main editor tmux panes and I need to open a quick file, I will do it there instead of moving back to my main editor vim session. This is usually due to the file needing to be opened is outside the cwd of the main vim session.
If I'm just editing two completely unrelated files I don't see any advantages to this workflow over opening multiple instances. Maybe if you have plugins that are slow to start up?
A few reasons to prefer vim windows are diffs and sharing the same buffers when flipping between them.
Vim panes vs vim instances in tmux, who wins? It depends on the use case. In case you want to edit files that are completely independent of each other and you prefer not sharing registers between these files, then you are better of using tmux panes; however if the use case involves similar files and involves lot of copy pasting between the 2 buffers, then it is very much recommended that you use Vim panes as the sharing of registers proves its worth in this use case.