Mastering copy paste with vim

When your yanking and deleting, sometimes you come across “oh, shit” situations, where you replaced the text that you yanked with something you deleted or vice versa. Fear not, these two commands will save your day.

What you yanked (or copied) will be saved in “0 register, so to paste what you yanked, the key sequence is: “0p

What you deleted (or cut) will be saved in the “1 register, so to paste what you deleted, the key sequence is: “1p

Of course, the generic version of this is for yanking to the “x register: “xy and pasting is: “xp

The generic version of deleting is kept as an exercise 😛

Using maven3 with vim

Vim’s ability to execute commands from vim itself adds a great deal of productivity. Although, it’s debatable that it’s the best editor for Java, I made an attempt to work with maven3 inside vim and integrate it with vim’s quick fix list. Disclaimer: I’m not a vim expert, just an enthusiast. Please drop a comment as this tip is in need of improvements.

First, change make to work with maven. I’ve added -q so that only errors will reach the console.

set makeprg=mvn\ compile\ -q\ -f\ pom.xml

Change the error format to match maven3 output. Disclaimer: This is not perfect, but it manages to pick up the maven3 errors.

 set errorformat=[ERROR]\ %f:[%l%.%c]%m

Change your working directory to the root of the maven project with :cd

Execute make with :make

Here’s the output I get.

Now, if you have errors it should show in the quick fix list as depicted below (Use :copen to open the quick fix list)

Now navigate and fix with :cn and :cp. Cheers!