Automatic Comment Prefixing

For a long time, I hated the fact that if I had something like this in Vim:

// foo{C}

Where {C} is the cursor, and hit o onto the next line, Vim would insert the comment bit for me:

// foo
// {C}

More often than not, I didn’t actually want that. Thankfully, as with a lot of my Vim problems, the dotfiles of Ben Orenstein came to my rescue with this line:

set formatoptions-=or

This stops Vim continuing the comment automatically.

As an aside, it seems like a good time to mention that my dotfiles are on Github also if you, like me, like trawling through other’s dotfiles for gems.

comments powered by Disqus… Click Here

 
 

Opening URLs from Vim

Big thanks to Keith Smiley for this tip to kickstart this blog once more!

Just discovered gx in vim. Totally amazed at how often I find things that will massively improve my usage.

— Keith Smiley (@SmileyKeith) February 8, 2015

From within Vim if you position your cursor over any URL and hit gx, the URL will be opened in your default browser. Simple and incredibly effective!

comments powered by Disqus… Click Here

 
 

vim-dispatch: I should have used this years ago

vim-dispatch is a plugin by Tim Pope that I’d heard a lot about but never really understood the benefits or what it offered me…until now.

Recently I’ve been working a lot with Makefiles. I’m writing my dissertation in Latex and compiling that through a Makefile, I have a couple of C projects which I’ve similarly used Makefiles to save me time, and I’ve also been using other build tools like Gulp, Grunt, or other command line tools like Bundle.

Essentially, something I have to do quite a lot is quickly drop out of Vim to run something, usually one of the aforementioned tools or often my tests too. The problem with these is that they take my focus out of Vim. Most of the time as well, I only care about the result of the program I ran if something went badly. If everything went OK, I don’t need to know. So taking my focus out of Vim and losing where I was isn’t worth it most of the time.

And that’s where Vim Dispatch comes in. It provides two commands. The first, :Make wraps around Vim’s :make, but runs it asynchronously, in the background. Then, once its done, it populates the quickfix list with any problems or errors. If nothing bad happens, you don’t get disturbed. And, most importantly, at no point is your focus taken from Vim. You can keep typing away and coding as your Make command runs in the background. The output from the command is added to the quickfix window, and the quickfix window is populated with the errors.… Click Here