Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Vimscript check if current buffer has unsaved changes

Tags:

vim

I currently have my status line set up so that it's orange in insert mode and white otherwise. I'd like to make it go another color when I drop back to normal mode if the file has any unsaved changes, as I regularly take a little walk down a rabbit hole wondering why my changes have not taken effect. The little "[+]" doesn't smack me in the face enough ;)

I can't find any functions that start with "buf" and look like predicates for dirtiness though. I assume one exists, but is named something else. I expect there to be something like bufdirty() or bufchanged(). Any pointers? :)

like image 496
d11wtq Avatar asked Oct 28 '12 08:10

d11wtq


1 Answers

I think that you are looking for

:echo &mod[ified]

which returns 1 if modified and 0 if not modified.

like image 76
romainl Avatar answered Oct 04 '22 13:10

romainl