You can add an auto command to your vimrc to have it automatically executed when a certain type of file is loaded. As an example, I use the following to convert tabs to spaces when a PHP file is loaded.
auto BufReadPost *.php retab!
See :help auto for the full info.
Monday, February 9, 2009
Wednesday, February 4, 2009
Editor Comparison
A friend sent this to me, and I thought it was pretty funny. I'm not sure of the original source. Thanks Nate!
UPDATE: The comic is from this blog. Good stuff!
Tuesday, January 27, 2009
Ignore the Modified Flag
There are times when I'm working on a temporary buffer, and I want to do something like a `gf' (go to file), but Vim insists that the buffer is modified and refuses to abandon the file. You can get around this by telling Vim the file isn't modified.
:set hidden
This effectively makes Vim treat the file like it's already saved. Please avoid using this for any production files as it can make Vim think that the file on disk is different than it actually is.
:set hidden
This effectively makes Vim treat the file like it's already saved. Please avoid using this for any production files as it can make Vim think that the file on disk is different than it actually is.
Make Windows Equal Height
If you have a bunch of split windows of disproportionate sizes, you can make them all equal by doing a `ctrl-w =' in normal mode.
Tuesday, January 20, 2009
Converting Tabs to Spaces
Here's a quick way to convert a tab-stopped file to a space-formatted file.
:set expandtab
:retab!
:set expandtab
:retab!
Thursday, January 15, 2009
Last Changed Text
Here are two helpful commands to get to the last changed or yanked text.
`[ - First character of previously changed or yanked text
`] - Last character of previously changed or yanked text
`[ - First character of previously changed or yanked text
`] - Last character of previously changed or yanked text
Wednesday, January 14, 2009
Extending History
You can allow Vim to store more history than the default (last 20 commands) by setting history as follows.
:set history=N (where N is how much history you want to keep)
:set history=N (where N is how much history you want to keep)
Subscribe to:
Posts (Atom)