tags:

views:

388

answers:

6

Hi

While surfing, I came to know that somebody has done Tower of Hanoi using vim. WOW!!!

Can you people share what all cool things you have been doing in vim.

Thanks

Aman Jain

Edit: Not sure about the Tower of Hanoi solution using vim being all that useful. But I think this question should be re-opened to allow people to comment on any useful things that they've done using vim. For me? See my answer below. (-:

+1  A: 

I was working on a system that had massive log files. We're talking 30,000 10MB logs.

Per day!

Distinguishing between log messages that were coming from the middleware (same company but custom rolled) and our application was getting tedious.

That is until I wrote some custom vim syntax parsing so that anything vim displayed in green was from the middleware (done by the guys in Sophia Antipolis near Cannes) as opposed to anything vim displayed in blue that was from our application software that sat over the top of the SA code.

I also added highlighting to really make exceptions stand out with white lettering on a read background!

Made life so much easier! And it wasn't that hard to do!

Thanks vim!

cheers,

Rob

Rob Wells
+3  A: 

I'm using vim to syntax-color code in my blog and lecture notes. A single Perl line

system  "$vimrt\\gvim.exe", qq{ 
  -c "edit /tmp/tmpcode.$ext " 
  -c "source $vimrt/syntax/2html.vim" 
  -c "write! /tmp/tmpcode.html" 
  -c "qa!"};

converts the code into nicely-colored HTML. I know there are stand-alone tools for doing this, but vim is already installed on my system, so this is one less tool to install.

Diomidis Spinellis
+1  A: 

I couple of months ago I wrote a vim script to save a complete history of all my edits, so I could inspect and measure my programming performance.

Diomidis Spinellis
+1  A: 

I'm using vim a lot recently to edit XML files. I got the xmledit plugin for vim working. Now vim creates closing tags for me, I can enclose highlighted text in an XML tag, and jump to balancing XML tags. It saves a lot of repetitive typing, reduces mistakes, and increases my productivity.

Bill Karwin
+4  A: 

vim has a set of commands that integrate with development tools such as make, gcc, and ctags. You can build your project, navigate to warnings and errors, and jump to function/variable definitions without leaving the editor:

  • :make builds the project.
  • :cl lists warnings and errors.
  • :cc takes you to the to line in the source code that generated the current error.
  • :cn navigates to the next error.
  • :cp navigates to the previous error.
  • :tag name navigates to the definition of the token name. (See man ctags to generate an index of tokens; sometimes make tags will do this automatically.)
  • Pressing Ctrl+] navigates to the definition of the token under the cursor.
Adam Liss
+2  A: 

I found myself struggling to be more efficient in vim compared to other non-modal text editors until I learned about "text-objects". Understanding this concept really improved my productivity and also gave me a new way of looking at text which in turn made it easier to deeply understand other vim concepts that I had only understood ephemerally before.

:help text-objects

Joe Holloway