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.

5 comments:

graywh said...

Or you could "set hidden" in your vimrc to allow vim to hide modified buffers.

Travis Whitton said...

Thus the reason I started this blog... to learn from the community ;-).

Dr Foobario said...

you could also use a scratch buffer... there are a bunch of plugins on vim.org to handle them but all you really need to do is set these options: http://vim.pastey.net/107112

Easy enough to make your own :Scratch command

Sundar said...

I think you should update the post with the 'set hidden' method. It is much preferred and in fact recommendeded as a default for all users by the #vim IRC channel.

Travis Whitton said...

Updated based on reader feedback. Thanks guys.