Nicolás Brailovsky


A modern blog

Archive for the ‘Vim Tips’ Category

Vim Tip: Converting to a Beamer frame

author Posted by: nico on date Dec 1st, 2011 | filed Filed under: Vim Tips

Today we’ll learn how to convert the text under the cursor to a Beamer frame, yet it’s easy to apply the same technique for other stuff:

map xi\begin{frame}{TITLE}\end{frame}kp

Lets analyze it
* xi cut whatever is selected and enter insert mode
* \begin{frame}{TITLE}\end{frame} write the beamer frame declaration
* kp go up one line and paste what was on the buffer

You can do something like this whenever you need to map text in Vim, it’s very easy.

Vim: Ni! Ni! Ni! Ni!

author Posted by: nico on date Jun 2nd, 2011 | filed Filed under: Funny, Vim Tips

Even though I have vim a Vim fan for a long time there still is a lot of stuff which amazes me about this little editor,  and this thing I last learned about it is in the “ZOMG that’s so cool I’m about to pee my pants” category. Unfortunately, if I were to draw a Venn diagram of the people who may find it cool I’d have to intersect the group of people reading my blog (yes, very small) with the group of people who like Vim and Monty Python. So, here’s to the null group:

Type :Ni! in Vim and be amazed, it’ll reply back: Do you demand a shrubbery?

Just how cool is that?

 

 

Vim Tip: Vigor

author Posted by: nico on date Feb 15th, 2011 | filed Filed under: Funny, Vim Tips, WTF
Oh man. Just do a search on google images for Vim + Vigor. There are so many WTF images to choose from, I just can’t decide. Apparently since Vim is the name of sexual enhancement drug or something like that, combining Vim and Vigor is a formula for fun.

Well, Vim and Vigor have a different meaning in Linux. Just do an apt-get install vigor, then run it. You’ll have lots of fun with Vim’s evil cousing, I promise.

Vim Sexual Care

author Posted by: nico on date Sep 2nd, 2010 | filed Filed under: Funny, Vim, Vim Tips, WTF
Vim bestows its users all sort of magical properties, among which now we can count increased sexual performance. I bet you didn’t know, but Vim can help you keep your girl happy for days without end. Don’t believe me? Check this page.

Thanks for flying vim

author Posted by: nico on date Jul 15th, 2010 | filed Filed under: Vim Tips

Have you ever used Vim through ssh and saw your xterm title changes to “Thanks for flying vim”? It happens a lot to me, and I usualy notice about an hour later. I’m not sure what’s the use of this, I guess it’s related to Vim airlines (no, really, check vim-avia.com), but it can be turned off:

When using vim in an xterm it renames the title of that window to “Thanks for flying vim” on exit.

Q: How to turn off the message “Thanks for flying vim”?
A: :set notitle

http://www.vmunix.com/vim/answ.html

Vim tips: make things work again

author Posted by: nico on date Jun 29th, 2010 | filed Filed under: Vim Tips
Are you using :make within vim? If you are, then you probably noticed that getting lots of compiler errors is not uncommon, and that vim has a tendency of jumping to the first error found… but what happens if you want to see subsequent errors too, because you’re a really crappy programmer and need to find the 10 or 20 errors you just introduced with your single line edit?

Luckily Vim is always the anwser, just use cnext and cprev until you reach the error you are looking for.

Vim tips: make things work

author Posted by: nico on date Jun 11th, 2010 | filed Filed under: Vim Tips
So, you are an uber console geek, using only vim and the command line to compile all your projects, execute the tests, blah blah blah… if only you could squeeze that microsecond lost whenever you switch from vim to compile you’d be 1e-4 seconds more productive… oh, wait, you can!

Whenever you think you’re project is good enough to compile just hit :make to be proven wrong. Type :make test to run your tests (because you are using TDD, aren’t you?) and watch all those red flags fly by.Also, add the following mapping to your ~/.vimrc for an extra happy coding session:

  1. map <F5> :make
  2. map <F6> :make test

Vim tip: reuse gVim instance

author Posted by: nico on date May 14th, 2010 | filed Filed under: Vim Tips
/* Usual rant about Vim being great */, /* usual rant about everything else being plain awful */. /* Comment stating that if you don’t use Vim then you suck */. And now, one more reason to use gVim: instance reuse! Yes, you can save many many KB or RAM by using –remote-tab-silent when openning a document in gVim. (clearly this would have been “many many GB of RAM” if we were talking about emacs).

If you don’t like adding –remote-tab-silent each and every time you use gVim to open a file, then you are a lazy bum and I congratulate you. Define an alias in your bashrc to save precious typing microseconds too.

/Sarcasm mode off

Vim tip: Word count

author Posted by: nico on date Apr 20th, 2010 | filed Filed under: Vim Tips
Trying to count words is a common task. Whenever you’re writting a report for class, that is. There are some legitimate reasons but they don’t matter now: it’s a great chance to show off how great Vim is.

First method: Type ggVgY”*p to copy the whole text. Then paste it into word and use word count.
Second method: Type %!wc -w, which executes wc on each line.
Third method: Type g^g (g, CTRL+g) and watch the bottom of your screen.

As ussual, Vim rocks.

Vim tip: Remapping

author Posted by: nico on date Mar 31st, 2010 | filed Filed under: Vim Tips
We all know is the funnier editor in the world. You can even use it to rot13 all your code and have lots of laughs when committing. But what if you want to automagicaly change a random word into another word? Well then inoremap comes handy, just adding this to your ~/.vimrc:
  1. inoremap hola mundo

and suddenly whenever typing “hola” you’ll see “mundo” instead. LOL. I guess it’s useful to fix typos, or to autocomplete code. Or to change “Hello” into “Fuck you” in you friend’s vimrc, whichever you think it’s appropriate..