I used to work with netbeans and it always put an asterisk and changed the tab color when the file had changed since last save. Is there any way to make vim do something similar, that is, remind me that I haven't saved the file?
I know that there is a way to have it save automatically once in a while, but I don't want to do that.
You can use the m
flag in the 'statusline'
option to add a [+]
if file is modified. Note that in order to see the statusline, you'll need to set 'laststatus'
to be greater than 0 (1-Only shows status line if there are two or more windows, 2-Always).
If you're using a GUI-version, such as MacVim, you may prefer to set 'titlestring'
, which uses the same syntax but will alter the name of the window in your window-manager.
:set laststatus=2
:set statusline=[%n]\ %<%f%h%m
This will display:
[
: literal%n
: buffer number]
: literal\<Space>
: a space%<
: Truncate the field at the beginning if too long%f
: Path to the file in the buffer, as typed or relative to current
directory.%h
: Help buffer flag, text is "[help]".%m
: Modified flag, text is "[+]"; "[-]" if 'modifiable' is off.For more information see:
:help status-line
If the terminal displays its title somewhere, it's possible to use
:set title
to display whether the file is modified: a +
is displayed after the file name if it's modified.
However, a file can have +
at the end of its file name. For most files this should work fine.
Source: https://stackoverflow.com/a/13244715/5267751
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With