• Cosimo Orban

Vim plugins and .vimrc settings we love

Vim is great. Anyone who works with it knows there is no wrong way to configure it, but over the years, I have found some particular plugins and .vimrc settings which work well for me. I will go over a few of my favorites.

Vundle

This is a plugin manager for vim. Once this is installed, all other plugins become simple to install. It can even clone plugin repos from github for you, so all you need to know is the github path and it will do the rest.

Vim-Fugitive

If you use git, then vim-fugitive is for you. It is a great wrapper around git, but the command I use everyday is:Gblame. This command creates a small split showing who touched each line of your code last, the time/date, and the git commit-sha of that last change. Checkout the plugin docs for the other great ways it can make your life easier.

Ctrlp

Ctrlp combined with the silver searcher makes for incredibly quick file navigation in vim. Instead of exiting vim, you just press ctrl-p, and you get a dynamic search window, which updates as you type with search results within the group of folders/subfolders you are working in. It works very well in combination with vim splits.

Vim Split Navigation

If you work with many splits at a time like I do, these shortcuts will save you life (and hands). Just add these lines to your .vimrc:

" split key mappings
nnoremap <C-J> <C-W><C-J>
nnoremap <C-K> <C-W><C-K>
nnoremap <C-L> <C-W><C-L>
nnoremap <C-H> <C-W><C-H>

They simply make it so you can press ctrl-h(j,k,l) to navigate between splits instead of need to do the default ctrl-w, ctrl-h.

YouCompleteMe

This one is not for everyone, but it adds in IDE like text completion to vim. It's installation isn't super simple, as it has a simple compile step, and if you are on OS X you will want to make sure you have brew installed and are using the latest version of vim, not what ships with OS X, but, if you appreciate good code completion then it is totally worth it.

TCommemnt

This one makes commenting out lines in vim simple.gcc(the vim command, not the compiler) will comment out a line, or uncomment a line if it is commented. Better yet, it works like most other vim commands do, so you can select a group of text and hit gc to comment out the whole block. Also it's aware of the language you are working in and does the appropriate comment type for the language.

Make Vim Remember What Line You Were On

The default behavior for vimis that you will start at line 1 of a file upon opening. Add the following lines to your .vimrc and, in most cases, vim will now start you off where you last closed the file you are opening. So if you were working on a file and were at line 215, saved and closed, then found you made a mistake in your code, now when you reopen that file, you will start again on line 215.

" This beauty remembers where you were the last time you edited the file, and returns to the same position.
au BufReadPost * if line("'\"") > 0|if line("'\"") <= line("$")|exe("norm '\"")|else|exe "norm $"|endif|endif

While I have covered some of, what I feel, are the most useful vim plugins and settings, there are many others which I haven't talked about. Check out my github repo for my complete .vimrc, and other possibly useful 'nix configs.



0 views

Follow us at:

  • LinkedIn
  • Twitter
  • YouTube
  • Facebook

MES

MES for OEMs

MES for Service Bureaus

Extension Modules

About

Company Overview

Jobs

Support

Resources

Machine Integrations

Software Integrations

Contact Us

Philadelphia, PA, USA

Member of

Privacy Policy

Terms of Use

AUTHENTISE © COPYRIGHT 2020. ALL RIGHTS RESERVED.