There are a plethora of questions where people talk about common tricks, notably "Vim+ctags tips and tricks".
However, I don't refer to commonly used shortcuts that someone new to Vim would find cool. I am talking about a seasoned Unix user (be they a developer, administrator, both, etc.), who thinks they know something 99% of us never heard or dreamed about. Something that not only makes their work easier, but also is COOL and hackish. After all, Vim resides in the most dark-corner-rich OS in the world, thus it should have intricacies that only a few privileged know about and want to share with us.
:%TOhtml
Creates an html rendering of the current file.
Map F5 to quickly ROT13 your buffer:
You can use it as a boss key :).
Macros can call other macros, and can also call itself.
eg:
...will delete the first word from every line until the end of the file.
This is quite a simple example but it demonstrates a very powerful feature of vim
Often, I like changing current directories while editing - so I have to specify paths less.
Assuming you have Perl and/or Ruby support compiled in,
:rubydo
and:perldo
will run a Ruby or Perl one-liner on every line in a range (defaults to entire buffer), with$_
bound to the text of the current line (minus the newline). Manipulating$_
will change the text of that line.You can use this to do certain things that are easy to do in a scripting language but not so obvious using Vim builtins. For example to reverse the order of the words in a line:
To insert a random string of 8 characters (A-Z) at the end of every line:
You are limited to acting on one line at a time and you can't add newlines.