]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - vimrc
vimrc: Use echoerr to warn about possible template files.
[config/dotfiles.git] / vimrc
diff --git a/vimrc b/vimrc
index c5941692bd497a23e9e04338ce3272c1c8ba0148..5bc0894bb96d27f5a174276aa8c84b13c7b57ec1 100644 (file)
--- a/vimrc
+++ b/vimrc
@@ -303,7 +303,7 @@ if has('statusline')
     " If there's more than one buffer return "/<nr>" (e.g. "/05") where <nr>
     " is the highest buffer number, otherwise return nothing. Used in
     " 'statusline' to get an overview of available buffer numbers.
-    function! StatuslineBufferCount()
+    function! s:StatuslineBufferCount()
         let l:bufnr = bufnr('$')
         if l:bufnr > 1
             let l:result = '/'
@@ -326,7 +326,7 @@ if has('statusline')
     " Like %f but use relative filename if it's shorter than the absolute path
     " (e.g. '../../file' vs. '~/long/path/to/file'). fnamemodify()'s ':.' is
     " not enough because it doesn't create '../'s.
-    function! StatuslineRelativeFilename()
+    function! s:StatuslineRelativeFilename()
         " Display only filename for help files.
         if &buftype == 'help'
             return expand('%:t')
@@ -386,7 +386,7 @@ if has('statusline')
     endfunction
 
     " Return current syntax group in brackets or nothing if there's none.
-    function! StatuslineSyntaxGroup()
+    function! s:StatuslineSyntaxGroup()
         let l:group = synIDattr(synID(line('.'), col('.'), 1), 'name')
         if l:group != ''
             return '[' . l:group . '] '
@@ -395,22 +395,33 @@ if has('statusline')
         endif
     endfunction
 
+    " Short function names to make 'statusline' more readable.
+    function! SBC()
+        return <SID>StatuslineBufferCount()
+    endfunction
+    function! SRF()
+        return <SID>StatuslineRelativeFilename()
+    endfunction
+    function! SSG()
+        return <SID>StatuslineSyntaxGroup()
+    endfunction
+
     set statusline=
     " on the left
-    set statusline+=%02n  " buffer number
-    set statusline+=%{StatuslineBufferCount()} " highest buffer number
+    set statusline+=%02n              " buffer number
+    set statusline+=%{SBC()}          " highest buffer number
     set statusline+=:
     if has('modify_fname') && v:version >= 700 " some functions need 7.0
-        set statusline+=%{StatuslineRelativeFilename()} " path to current file
-        set statusline+=\     " space after path
+        set statusline+=%{SRF()}      " path to current file
+        set statusline+=\             " space after path
     else
-        set statusline+=%f\   " path to current file in buffer
+        set statusline+=%f\           " path to current file in buffer
     endif
-    set statusline+=%h    " [help] if buffer is help file
-    set statusline+=%w    " [Preview] if buffer is preview buffer
-    set statusline+=%m    " [+] if buffer was modified,
-                          " [-] if 'modifiable' is off
-    set statusline+=%r    " [RO] if buffer is read only
+    set statusline+=%h                " [help] if buffer is help file
+    set statusline+=%w                " [Preview] if buffer is preview buffer
+    set statusline+=%m                " [+] if buffer was modified,
+                                      " [-] if 'modifiable' is off
+    set statusline+=%r                " [RO] if buffer is read only
 
     " on the right
     set statusline+=%=                " right align
@@ -890,10 +901,10 @@ if has('autocmd')
             autocmd InsertLeave * set nopaste
         endif
 
-" Write file when running :mak[e] before 'makeprg' is called. QuickFixCmdPre
-" doesn't exist in older Vims.
+" Write all files when running :mak[e] before 'makeprg' is called.
+" QuickFixCmdPre doesn't exist in older Vims.
         if exists('##QuickFixCmdPre')
-            autocmd QuickFixCmdPre * write
+            autocmd QuickFixCmdPre * wall
         endif
 
 " Don't ignore case while in insert mode, but ignore case in all other modes.
@@ -916,9 +927,7 @@ if has('autocmd')
                 return
             endif
 
-            echohl WarningMsg
-            echo 'Do not edit this file! (Maybe a template file.)'
-            echohl None
+            echoerr 'Do not edit this file! (Maybe a template file.)'
         endfunction
         autocmd BufRead * call <SID>SearchForDoNotEditHeader()