In my last post I’ve described some of the features and plugins I use in Vim. Last week, I took another dive into my .vimrc file and made some changes in my vim keybindings which I’m quite thrilled about. I was in a mood to share, hence this post.
Leveraging the comma
After watching a couple of nice videos on Vim by Derek Wyatt (thank you for those, awesome!), I’m now using comma as a shorthand key for many things. I’ve added a number of keybindings to make my life easier:
" Some keybindings for utilizing vim-fugitive (plugin that provides git functionality in vim) nmap ,gs :Gstatus nmap ,ge :Gedit nmap ,gw :Gwrite nmap ,gr :Gread nmap ,gd :Gdiff nmap ,gc :Gcommit " Mappings that provide easy access to .vimrc file and a nice way to source it directly :nmap ,ev :e $MYVIMRC :nmap ,sv :so $MYVIMRC " Key for toggling search highlighting. :noremap ,h :set hlsearch! hlsearch?
As I’m coding in vim, it is very beneficial to have direct access to the version control system in which I push my code. Usually I have seperate terminals open on my machine for these things. I would be leveraging the power of tmux (for example) to switch between them easily. With these added keybindings, I never have to leave my editor while coding! A time-saver for sure.
As I’m twiddling with my vim configuration often, it helps to also have 2 keybindings in place to open my .vimrc file with great ease. It’s a very small time-saver as I can easily type out the command by hand, but every shortcut helps!
The keybinding I use most is definetly the last one in the list. While doing a search query in vim, it highlights all the found results in the file that is open. This is very usefull. However, when I’ve found what I’m looking for I very much want to get rid of the highlights. I use that one fairly often during work.