Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing vim's status line's "file modified" flag to be more noticeable

Tags:

vim

statusline

I do this all the time:

Edit a file, go back to the terminal and execute the script I'm writing… only to realize that I haven't written it to disk yet.

How do I make it so that vim is basically shouting at my eyes whenever the file is unwritten? That tiny [+] isn't good enough. Ideally, I'd like to either increase the number of red plusses being shown, or something more drastic.

FOR INSTANCE, I'm using powerline (purely in an attempt to get a more noticeable 'file has been modified' notifier). I think it'd be pretty great if the main colour at the bottom of the bar changed whenever the file has not been saved.

Any ideas?

like image 438
phillmv Avatar asked Sep 26 '12 21:09

phillmv


3 Answers

You can set vim to display the file modified flag 5 times if you want.

set statusline+=%m

This adds it one time. Increase the number of "%m" to whatever number you want. Further explanations and tricks here: http://got-ravings.blogspot.co.at/2008/08/vim-pr0n-making-statuslines-that-own.html

like image 107
blues Avatar answered Nov 01 '22 02:11

blues


I have written the StatusLineHighlight plugin for that. It changes the color of the statusline to red (customizable) for modified buffers.

It won't work together with Powerline or other fancy statusline modifications, though.

like image 44
Ingo Karkat Avatar answered Nov 01 '22 02:11

Ingo Karkat


It is not the answer to the question you asked, but why don’t you just do

set autowrite

to make the problem you mentioned (“go back to the terminal and execute the script I'm writing… only to realize that I haven't written it to disk yet”) go away: this option makes vim save changes you did when you suspend it (note: not when you use :shell to spawn a new shell).

For powerline the only thing you can do easily is to edit colorscheme to make more noticeable highlighting: copy autoload/Powerline/Colorschemes/default.vim to ~/.vim/autoload/Powerline/Colorschemes/my.vim, find Pl#Hi#Segments(['fileinfo.flags' and in each line add the second color (background one): transform ['brightestred', ['bold']] to ['white', 'brightestred', ['bold']] and so on. Then add

let g:Powerline_colorscheme='my'

to the vimrc and run :PowerlineClearCache.

like image 38
ZyX Avatar answered Nov 01 '22 02:11

ZyX