Word count
I frequently need to count words in a file from inside Vim. There are many ways to do this:
* this uses the external utility ”wc”: ”:!wc %”
* count words in the file: ”g
I frequently need to count words in a file from inside Vim. There are many ways to do this:
* this uses the external utility ”wc”: ”:!wc %”
* count words in the file: ”g
Unarguably, the holy war of the geeks centers around the [[http://vim.sf.net/|Vi]] vs [[http://www.gnu.org/software/emacs/emacs.html|Emacs]] debate—which is the editor to rule them all?
No, this post is not about ending that war, or even trying to. This is just a response to my amazement at how deep rooted this war continues to be in our community.
So this wednesday as I was waiting in the hallway to meet with Amin, I heard him say something about Vi and Emacs to one of his students and how none of these editors even close in terms of productivity when compared to the mature IDEs (such as Visual Studio or Eclipse) for serious programming. I used to be a devout Emacs user for a long time (around 4 years) before I moved to Vim, and I’ve never been happier.
Naturally when I went in, I asked him about his take on Vi vs. Emacs. Turns out that Amin is a devout Emacs user, right from his undergrad days. Apparently in his time Vim was not popular, and Vi does kind of suck in a way compared to Vim. Being the good Vim lover that I am, I engaged him with all the neat things that my Vim setup could do, and he was genuinely surprised, and happily, interested too! So its quite likely that I might have to give him a demo of what Vim can do these days very soon :)
Here are some nice reads:
* [[http://thomer.com/vi/vi.html|Vi lovers page]]
* [[http://www.io.com/~dierdorf/emacsvi.html|Emacs and Vi]] (note the and, instead of the usual vs)
* [[http://www.newsforge.com/article.pl?sid=01/12/04/0326236|Newsforge article on the holy geek war]]
* [[http://www.tarunz.org/~vassilii/srom/|Suck-o-meter]]
When you open a file using ”:e filename”, and you want to use tab-completion for the filename, by default Vim cycles through the various filenames starting with that prefix. I don’t like this default behavior. For me, its much more efficient to just get a list of matching names in a mini-buffer and then I can just choose which one I intended. Happily, this is easily achieved by doing ”set wildmode=list:longest”. As always, refer to ”:help wildmode” for details.
A jump happens when you jump to a mark, or a search location, or top or bottom of the file. You can use ”Ctrl-O” or ”Ctrl-I” to navigate through the jump list. You can see the list of available jump locations by executing ”:jumps”
Vim also allows you to navigate through the locations of the edits you’ve made. Do this using ”g;” and ”g,”
Here’s a killer Vim tip: there’s now a [[http://www.vim.org/tips/rss2.php | RSS feed] for the Vim tips from [[http://www.vim.org/ | Vim online]]