]> git.phdru.name Git - dotfiles.git/blobdiff - .vimrc
.vimrc: Add functions `Code`/`Text`
[dotfiles.git] / .vimrc
diff --git a/.vimrc b/.vimrc
index 147fb38d400f64de2251c0ee30dec65804ce86ae..c4e396cc393523f8c4014a525f518d21445bbfe9 100644 (file)
--- a/.vimrc
+++ b/.vimrc
@@ -22,6 +22,10 @@ if exists("b:wrap") " Only do this on the second and subsequent :source's
       set nomodified
    endif
    unlet fenc ftype mod
+
+elseif filereadable($VIMRUNTIME . "/defaults.vim")
+   unlet! skip_defaults_vim
+   source $VIMRUNTIME/defaults.vim
 endif
 
 " No, it is not VI, it is VIM! It is important to set this first, because this
@@ -34,6 +38,7 @@ behave xterm
 " 2 moving around, searching and patterns
 
 set ignorecase    " Ignore case in search patterns
+set noincsearch   " No incremental searching
 set smartcase     " Match 'word' case-insensitive and 'Word' case-sensitive
 
 set nostartofline " Keep cursor's column
@@ -47,6 +52,7 @@ set list          " listchars only works with 'list'
 " Show tabs, non-breaking/trailing spaces, long lines
 set listchars=tab:>_,nbsp:_,trail:_,extends:+,precedes:+
 " Another usefull additions: eol:$,space:_
+set scrolloff=0 " number of screen lines to show around the cursor
 set wrap          " Visually wrap long lines
 
 " With 'set wrap' wrap long lines at a character in 'breakat'
@@ -81,7 +87,9 @@ set titlestring=%t%(\ %M%)%(\ (%{expand(\"%:p:h\")})%)%(\ %a%)\ -\ [%{$USER}@%{h
 
 " 9 using the mouse
 
-set mouse=ar      " Use mouse in all modes, plus hit-return
+if has('mouse')
+   set mouse=ar      " Use mouse in all modes, plus hit-return
+endif
 
 " 12 messages and info
 
@@ -177,15 +185,16 @@ set fileencodings=ucs-bom,us-ascii,utf-8,koi8-r,cp1251,cp866,latin1
 " ' - number of files for which the marks are remembered;
 " " and < - maximum number of lines saved for a register;
 " s - maximum size of an item in Kbytes.
+set viminfo=!,h,'50
 if version < 603
-   set viminfo=!,h,'50,\"1000
+   set viminfo+=\"1000
 else
-   set viminfo=!,h,'50,<1000,s10
+   set viminfo+=<1000,s10
 endif
 
 " c - convert viminfo to the current encoding;
 if has("iconv")
-   set viminfo^=c
+   set viminfo+=c
 endif
 
 " Removable media paths
@@ -564,6 +573,9 @@ function! SlowTerm()
    set nowildmenu
    set wildmode=list:longest
    set viminfo=!,h,'10,<100,s5
+   if has("iconv")
+      set viminfo+=c
+   endif
    syntax off
    highlight NonText cterm=NONE ctermfg=NONE
 endfunction
@@ -583,7 +595,7 @@ endif
 
 
 " From Tip 212:
-" http://vim.wikia.com/wiki/Setting_file_attributes_without_reloading_a_buffer
+" http://vim.fandom.com/wiki/Setting_file_attributes_without_reloading_a_buffer
 
 if executable('chmod')
    function! SetExecutableBit(x)
@@ -600,6 +612,7 @@ if executable('chmod')
          echoerr 'Error running chmod: ' . v:shell_error
       endif
       checktime
+      autocmd! FileChangedShell <buffer>
    endfunction
    function! _BufChangedCB()
       autocmd! FileChangedShell <buffer>
@@ -607,6 +620,15 @@ if executable('chmod')
    command! ToggleXbit if executable(expand("%:p")) | call SetExecutableBit(0) | else | call SetExecutableBit(1) | endif
 endif
 
+function! Code()
+    setlocal tabstop=8 softtabstop=4 shiftwidth=4 expandtab
+endfunction
+command! Code call Code()
+
+function! Text()
+    setlocal tabstop=8 softtabstop=3 shiftwidth=3 expandtab
+endfunction
+command! Text call Text()
 
 " ----------
 " From http://slobin.pp.ru/vim/_vimrc.html
@@ -650,7 +672,7 @@ endif
 
 " Called automagically after every buffer read, enables fileencoding
 " setting from modeline (see Tip #911:
-" http://vim.wikia.com/wiki/How_to_make_fileencoding_work_in_the_modeline)
+" http://vim.fandom.com/wiki/How_to_make_fileencoding_work_in_the_modeline)
 function! AutoEncoding()
   if &modified && &fileencoding != ""
     call SetupEncoding(&fileencoding)
@@ -773,5 +795,15 @@ command! UName Uname
 endif
 " ----------
 
+if has("iconv")
+function! SetViminfoEncoding()
+   " Set universal encoding for .viminfo
+   if &encoding != 'utf-8'
+      set encoding=utf-8
+   endif
+endfunction
+autocmd VimLeavePre * call SetViminfoEncoding()
+endif
+
 " This has to go to the very end of ~/.vimrc to allow reading the .vimrc
 set secure        " safer working with script files in the current directory