Before I say anything, I am NOT a VIM power user. But I do use it every day, and I use it for all sorts of tasks. In this article I'll share some of these.
Duplicates
In the course of my workday I sometimes have to clean out dups, or perhaps just identify them. Removing dups is easy:
:sort u
For identifying them I clone my file, and open it in a vertical split (:vsplit), so I have both my original and the cloned side by side. Then I sort both (:sort). In the cloned file I remove dups:
:sort u
Then in each panel I do a diff:
:vimdiff
That will highlight where the dups were removed.
Tediousness
This is something that comes up all the time, and takes numerous forms from formatting code to creating multiple rows of data or code etc. For any repeatable task in VIM I break out the macros. I love macros. And in VIM macros are super powered since it is keyboard driven so nearly everything can be recorded in the macro. I utilize the clipboard or in really intense cases, even multiple files. I can select a line, cut it, switch to a blank document, mess with it there, then copy it back into the first document. I will discuss macros in VIM in greater detail in a future article.
Grepping
I don't like Windows, but am often stuck with it (work). To satisfy my love of nix a little, I often utilize:
:vimgrep
And always have the vimcommander plug in installed for use as a commander style file manager (But with VIM key mappings!)
I don't utilize any other plugins in VIM, I'll have to dig into them and further push the limits of what VIM can do. In future articles I'll share some of the powerful commands I've come across.
No comments:
Post a Comment