]> ruderich.org/simon Gitweb - config/dotfiles.git/blobdiff - vimrc
vimrc: Fix compatibility with Vim 6.4 and later.
[config/dotfiles.git] / vimrc
diff --git a/vimrc b/vimrc
index f19fa910abfc9f16600b179b840ef0051123a7dc..8a6e07f4dc7ecf25224bc5ea4533232b881ddc76 100644 (file)
--- a/vimrc
+++ b/vimrc
@@ -105,9 +105,6 @@ if exists('+cryptmethod')
     set cryptmethod=blowfish
 endif
 
-" Create new split windows on the right (and not left).
-set splitright
-
 " Clear all vimrc-related autocmds. Has to be done here as the vimrc augroup
 " is used multiple times. Necessary to support reloading the vimrc.
 if has('autocmd')
@@ -236,6 +233,11 @@ endif
 " (add ! to override)" warning when switching buffers.
 set hidden
 
+" When splitting vertically put the new window right of the current one.
+if has('vertsplit')
+    set splitright
+endif
+
 
 " DISPLAY SETTINGS
 
@@ -385,6 +387,23 @@ if has('statusline')
         endif
     endfunction
 
+    " Display unexpected 'fileformat' and 'fileencoding' settings.
+    function! s:StatuslineFileFormat()
+        if &fileformat != 'unix'
+            return '[' . &fileformat . ']'
+        else
+            return ''
+        endif
+    endfunction
+    function! s:StatuslineFileEncoding()
+        if &fileencoding != '' && &fileencoding != 'utf-8'
+                \ && &filetype != 'help'
+            return '[' . &fileencoding . ']'
+        else
+            return ''
+        endif
+    endfunction
+
     " Return current syntax group in brackets or nothing if there's none.
     function! s:StatuslineSyntaxGroup()
         let l:group = synIDattr(synID(line('.'), col('.'), 1), 'name')
@@ -402,6 +421,12 @@ if has('statusline')
     function! SRF()
         return <SID>StatuslineRelativeFilename()
     endfunction
+    function! SFF()
+        return <SID>StatuslineFileFormat()
+    endfunction
+    function! SFE()
+        return <SID>StatuslineFileEncoding()
+    endfunction
     function! SSG()
         return <SID>StatuslineSyntaxGroup()
     endfunction
@@ -422,6 +447,12 @@ if has('statusline')
     set statusline+=%m                " [+] if buffer was modified,
                                       " [-] if 'modifiable' is off
     set statusline+=%r                " [RO] if buffer is read only
+    if v:version >= 700               " %#..# needs 7.0
+        set statusline+=%#Error#      " display warnings
+        set statusline+=%{SFF()}      "   - unexpected file format
+        set statusline+=%{SFE()}      "   - unexpected file encoding
+        set statusline+=%##           " continue with normal colors
+    endif
 
     " on the right
     set statusline+=%=                " right align
@@ -582,7 +613,7 @@ nnoremap <silent> <Leader>; :call setline(line('.'), getline('.') . ';')<CR>
 " and all nerds involved (godlygeek, strull in #vim on Freenode).
 if has('eval')
     function! s:VSetSearch()
-        let l:temp = @@
+        let l:temp = @@ " unnamed register
         normal! gvy
         " Added \C to force 'noignorecase' while searching the current visual
         " selection. I want to search for the exact string in this case.
@@ -901,10 +932,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.
@@ -927,9 +958,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()