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.
Let's see some pretty little IDE editor do column transposition.
Explanation
\(
and\)
is how to remember stuff in regex-land. And\1
,\2
etc is how to retrieve the remembered stuff.Remember everything followed by
^I
(tab) followed by everything.Replace the above stuff with "2nd stuff you remembered" followed by "1st stuff you remembered" - essentially doing a transpose.
Want to look at your :command history?
Then browse, edit and finally to execute the command.
Ever make similar changes to two files and switch back and forth between them? (Say, source and header files?)
Then tab back and forth between those files.
Something I just discovered recently that I thought was very cool:
Reverts the document back to how it was 15 minutes ago. Can take various arguments for the amount of time you want to roll back, and is dependent on undolevels. Can be reversed with the opposite command
:later
Make vim into a hex editor.
Revert.
Warning: If you don't edit with binary (-b), you might damage the file. – Josh Lee in the comments.
I often use many windows when I work on a project and sometimes I need to resize them. Here's what I use:
These mappings allow to increase and decrease the size of the current window. It's quite simple but it's fast.
Not an obscure feature, but very useful and time saving.
If you want to save a session of your open buffers, tabs, markers and other settings, you can issue the following:
You can open your session using: