Matt's getting into using the vi editor and it got me reminiscing. Honestly it's my unix editor of choice. Back in the good old days of QAD I had to work on every mainstream Unix flavor, and vi was the one editor that would be installed on all of them. Even now that I only tend to work on Linux it remains my editor of choice. And I have confidence that if I ever have to dig into an ancient HP-UX system I'll know exactly how to edit stuff. It's also handy if you have to work on a very strange keyboard, since you can do everything with only the a-z keys (plus escape).
Besides being ubiuitous, vi is so feature-packed that I doubt that any single person knows every single feature. I'm still learning stuff by watching colleagues - they'll do something cool and then I'll ask "whoa - how did you do that?'. A couple of fun examples:
1) substitution - just like sed - something like ':s/foo/bar' will replace the first instance of 'foo' on the current line with 'bar'. ':/foo/bar/g' will replace all instances on the current line, and ':%s/foo/bar/g' will replace within the whole file.
2) You can break into a shell w/ vi and do cool stuff with it - so for example if you are writing a message and want to give your network info, just do ':r !ifconfig' or ':r !ipconfig' if you're in windows. Voila, the output appears. Awesome. Note: the shell ability is just one reason why vi should _not_ be a sudo command - it's far too powerful in the wrong hands.
3) The period - repeats the last thing you did. Handy if I'm commenting two or three lines.
4) All kinds of little features - for example, the tilde will change the case of the highlighted character from upper to lower and vice-versa. Handy if you realize you mistyped the variable or were typing head-down with the caps lock on.
I've been using the vi editor for about 10 years now (wow!) and I'm still basically using the same functionality it's had the whole time - I'm not even getting into anything fancy yet, and at this rate I never will.
--Nate
Subscribe to:
Post Comments (Atom)
1 comment:
I'm still wowing about stuff in vim.
today I looked at 6 lines of code that needed to be indented more.
I was barely thinking as I typed v6j>>
They needed to be indented one more time, so I typed "." and was done.
So HOT!
And the % command on braces, parens and such is really very useful for me.
Post a Comment