How to make vim indicate that the file has changed since the last save?

I worked with netbeans and it always put an asterisk and changed the color of the tab when the file was changed since the last save. Is there a way to get vim to do something like this, that is, remind me that I did not save the file?

I know there is a way to keep it automatically once in a while, but I don’t want to do this

Thanks!

+6
source share
2 answers

You can use the m flag in 'statusline' to add the [+] file if the file has been modified. Please note that in order to see the status line, you need to set 'laststatus' more than 0 (1-Only shows the status bar if there are two or more windows, 2-Always).

If you are using a GUI version such as MacVim, you can set a 'titlestring' that uses the same syntax but changes the window name in your window manager.

Example:

 :set laststatus=2 :set statusline=[%n]\ %<%f%h%m 

This will display:

  • [ : literal
  • %n : buffer number
  • ] : literal
  • \<Space> : space
  • %< : crop the field at the beginning if it is too long
  • %f : path to the file in the buffer, both typed and relative to the current directory.
  • %h : help buffer flag, text "[help]".
  • %m : Changed flag, text "[+]"; "[-]" if "modifiable" is turned off.

For more information see

+5
source

Call :ls and you will see + in front of unsaved buffers

+3
source

Source: https://habr.com/ru/post/956807/


All Articles