Just a quick note. For you Mac & Vim users out there - MACVIM. It truly rocks.
Also, a quick "oh my gosh I'm so glad I finally found a command for this," and then a "doh, of course!"
I often launch Vim and then have to work on a set of files in some specific project directly. Its a pain to have to type something like:
:e ~/Documents/ProjectA/subProjectX/file1.py
:sp ~/Documents/ProjectA/subProjectX/file2.py
:sp ~/Documents/ProjectA/subProjectX/file3.py
over and over and over again. I've been looking for the command to set your 'current directory', and I found it: cd. Duh:
:cd ~/Documents/ProjectA/subProjectX
:e file1.py
:sp file2.py
:sp file3.py
So much better.
Thursday, July 10, 2008
Monday, July 07, 2008
Tuesday, July 01, 2008
Review of "100 Vim Commands every programmer should know"
This morning I woke to find that a number of blogs out there there have picked up an article called "100 Vim commands every programmer should know" over at CatsWhoCode.com. Of course, I had to go over there and scan down the list to see if there was something there that I might need to know.
Search
Commands under the 'Search' category are simple enough: straightforward word boundaries and regular expressions mixed in.
Replace
The 'Replace' category is much the same. Ranges are covered extensively. Unfortunately, I think it got a bit too general. The 'global' command was mixed in here, and only glossed over with the following paltry commands:
:g/string/d Delete all lines containing “string”
:v/string/d Delete all lines containing which didn’t contain “string”
Interestingly I'd never heard of the ':v' command, but now I know why...its equivalent to the ':g!' command.
An oldy but goody was included in the 'Replace' category as well, to with XML tags:
:%s#<[^>]\+>##g Delete HTML tags but keeps text
At the bottom of this section I saw "Change text to Rot13." Rot13?? Ah. To be honest I haven't in my paltry 14 years on the internet ever found myself using Rot13 for anything, so I have to say I'm a little surprise this makes it into the "Top 100". Onward.
Case
Amazing! I have a big black hole in my head when it comes to case commands. Oh no, nevermind. Funny how it is that you sometimes actually have to use the command sequences before you realize, oh...yeah, I know that. Duh. To deal with words I prefer the 'inner word' type commands. Rather than doing 'vE' to select a word as is done a couple times here, I would do 'viw'. I think you would find 'viw' more forgiving than 'vE' if you were whipping up a recording, say, as it'll actually select the whole word. 'vE' only selects the current position to the end of the word. Minor detail I suppose. I didn't know about this setting though. Sweet:
:set smartcase Ignore case in searches excepted if an uppercase letter is used
There were also a number of case replacements using sequences like:
:%s/\<./\u&/g Sets first letter of each word to uppercase
I'd tend to categorize this as 'Replace', but thats just me. Also, I don't often use the these generic sub replace commands in favor of the generic sub replace method. I'd do this more generic replace:
:%s/\<./\=toupper(submatch(0))/g
Hmm, yes. I should learn to use those other matches. Mines a bit verbose.
Okay, so I've only reviewed about 1/3'rd of the entire list. On the whole I think its a good list, though the categorization is a bit loose. There were a few good comments on the article (and the author acknowledged them as well; they should get a pat on the back for listening to the readers). Worst offense: leaving out recording macros. Definitely should have been in the top 100.
Search
Commands under the 'Search' category are simple enough: straightforward word boundaries and regular expressions mixed in.
Replace
The 'Replace' category is much the same. Ranges are covered extensively. Unfortunately, I think it got a bit too general. The 'global' command was mixed in here, and only glossed over with the following paltry commands:
:g/string/d Delete all lines containing “string”
:v/string/d Delete all lines containing which didn’t contain “string”
Interestingly I'd never heard of the ':v' command, but now I know why...its equivalent to the ':g!' command.
An oldy but goody was included in the 'Replace' category as well, to with XML tags:
:%s#<[^>]\+>##g Delete HTML tags but keeps text
At the bottom of this section I saw "Change text to Rot13." Rot13?? Ah. To be honest I haven't in my paltry 14 years on the internet ever found myself using Rot13 for anything, so I have to say I'm a little surprise this makes it into the "Top 100". Onward.
Case
Amazing! I have a big black hole in my head when it comes to case commands. Oh no, nevermind. Funny how it is that you sometimes actually have to use the command sequences before you realize, oh...yeah, I know that. Duh. To deal with words I prefer the 'inner word' type commands. Rather than doing 'vE' to select a word as is done a couple times here, I would do 'viw'. I think you would find 'viw' more forgiving than 'vE' if you were whipping up a recording, say, as it'll actually select the whole word. 'vE' only selects the current position to the end of the word. Minor detail I suppose. I didn't know about this setting though. Sweet:
:set smartcase Ignore case in searches excepted if an uppercase letter is used
There were also a number of case replacements using sequences like:
:%s/\<./\u&/g Sets first letter of each word to uppercase
I'd tend to categorize this as 'Replace', but thats just me. Also, I don't often use the these generic sub replace commands in favor of the generic sub replace method. I'd do this more generic replace:
:%s/\<./\=toupper(submatch(0))/g
Hmm, yes. I should learn to use those other matches. Mines a bit verbose.
Okay, so I've only reviewed about 1/3'rd of the entire list. On the whole I think its a good list, though the categorization is a bit loose. There were a few good comments on the article (and the author acknowledged them as well; they should get a pat on the back for listening to the readers). Worst offense: leaving out recording macros. Definitely should have been in the top 100.
Subscribe to:
Posts (Atom)