
Handy Keymaps in Vim - axiomdata316
https://aonemd.github.io/blog/handy-keymaps-in-vim
======
adrianrocamora
Since I can't control the mouse so well anymore due to health reasons I grew
to hate Kanban boards and Trello. Nowadays, the following goes into my
init.vim along with vimwiki and it has made my work much more enjoyable :)

""" 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>

~~~
AH2mdte8kPnJS
I loved this but wanted to generalize it a bit to clean it up and make it
portable across different computers.

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>
    
        ...

~~~
adrianrocamora
Lovely, it was a bit of a hack I came up with that I was trying out, but your
cleaned up version makes it look wonderful so into my init.vim it goes! Thanks
:)

------
joeldo
I've found a system wide mapping of 'Caps Lock' to 'Esc'(and vice versa) a
much better use of keyboard estate / ergonomics.

Although the mapping was prompted by Vim usage, it's surprisingly useful for
general computing as well.

~~~
boomlinde
IMO making it a control key is a better choice (I tried both at some point)
because chording with awkward keys is worse than just pressing them, and the
control keys are placed awkwardly on most keyboards. Since you can end
insertion mode with ^[ you then have a pretty comfortable chord that doesn't
stray far from the home row to replace the escape key.

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.

~~~
neonroku
Karabiner Elements is great for doing this kind of remapping on macOS

[https://pqrs.org/osx/karabiner/](https://pqrs.org/osx/karabiner/)

The equivalent for Windows would probably be AutoHotkey

[https://www.autohotkey.com/](https://www.autohotkey.com/)

~~~
Tsiklon
OS X can natively set Caps Lock (or any of the other modifiers) to
CTRL,ALT,CMD,Esc,Caps. in the Keyboard Pref Pane at least as of 10.13.

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.

------
franey
By far my favourite remap in (Neo)vim is to map : to ; and ; to ,

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 , ;

~~~
flukus
I just switch ':' and ';' along with '-' and '_' in insert mode, cut's out
probably 90% of shift key presses. Swapping the numbers and their shift
counterparts would probably save another 90%.

~~~
boomlinde
YMMV depending on what you are actually typing, though. I think I tend to
spend significantly less time issuing ex commands than I spend actually typing
things.

------
goblin89
As far as Vim split navigation goes (and especially for those of us using
Tmux), check out [https://github.com/christoomey/vim-tmux-
navigator](https://github.com/christoomey/vim-tmux-navigator).

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.

------
kpremote
I've noticed that there are not as many Vim/Emacs related posts on HN during
the past two years than before. And the discussions and upvotes have been less
enthusiastic.

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?

~~~
lone_haxx0r
Maybe everything to be said about vim has already been said. You can look at
those threads from 3 years ago and read about it if you want.

------
yinyang_in
I really like how his website displays so well in mobile. Beautiful work

------
fourier_mode
Is there any reason for not using Tmux instead of using panes in Vim?

~~~
jteppinette
Utilizing cross-window copy/paste, cross-window repeat, opening a new file
(window) with a single command vs new tmux pane then initializing vim. Those
are just a few of the many reasons. IMO, using a new tmux pane for each vim
instance would be a HUGE anti-pattern. Most people with the tmux/vim setup
will use a single tmux pane for vim, then N number of other tmux panes for
other required needs (compiling, tests, etc...).

~~~
nextlevelwizard
Do people usually have multiple vim splits open? At least I usually just have
one terminal with new tmux splits and usually one vim with multiple buffers I
switch between if needed.

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.

~~~
boomlinde
I typically split if I have some interrelated code that I need to cross-
reference, e.g. when refactoring. Especially if this code is in the same file,
in which case windows into the same buffer have the added benefit of
synchronized editing. Another example: when programming C, it is useful
sometimes to have the header in one vim window and the definitions in the
other. Or you're navigating via ctags, and it's convenient to view a tag in a
new window rather than change the buffer for the current window.

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?

