dot rc

Sign in or create your account | Project List | Help

dot rc Git Source Tree

Root/rc/vimrc

Source at commit 9a3ffc647ca2d2ad26779545738217e30e00679c created 3 years 7 months ago.
By Luciano M. F. Rocha, add byte-order-mark detection to list of file-encodings
1" vim:et:sw=2:ts=2
2" Use Vim settings, rather than Vi settings, must be the first option
3" for its side effects.
4set nocompatible
5
6" check for Byte-Order-Mark, then utf8, and finally assume latin1
7set fileencodings=ucs-bom,utf-8,latin1
8" force encoding when reading/writing with:
9" :e|w ++enc=encoding file
10
11" allow backspacing over everything in insert mode
12set backspace=indent,eol,start
13
14set nobackup " do not keep a backup file
15set history=50 " keep 50 lines of command line history
16set ruler " show the cursor position all the time
17set showcmd " display incomplete commands
18set incsearch " do incremental searching
19set nohlsearch " don't highlight search matches
20set showmatch " jump to matching bracket when inserting one
21set wildmenu " tab completion shows options above command line
22"
23"disabled: let filetype define it
24"set smartindent " do smart autoindenting when starting a new line
25
26syntax on " switch syntax highlighting on
27
28" Q, by default, switches to Ex mode; make it reformat the current paragraph
29" instead (more useful)
30map Q gqap
31
32" Map F1 to the ESC key in insert mode, and Help otherwise
33" together)
34imap <esc>[11~ <esc>
35map <esc>[11~ :h
36
37" F7 macro for toggling between syntax on and off
38map <F7> :if exists("syntax_on") <Bar>
39    \ syntax off <Bar>
40    \ else <Bar>
41    \ syntax enable <Bar>
42    \ endif <CR>
43
44" make grep also work well with a single file
45set grepprg=grep\ -nH\ $*
46
47" syntax highlighting inside C comment strings
48let c_comment_strings=1
49
50" assume sh is bash
51let g:is_bash=1
52
53" for zenburn, assume running in a bright environment
54"let g:zenburn_high_Contrast = 1
55
56" In many terminal emulators the mouse works just fine, thus enable it.
57" conflicts with c&p, disabled
58"set mouse=a
59
60" Convenient command to see the difference between the current buffer and the
61" file it was loaded from, thus the changes you made.
62command! DiffOrig vert new | set bt=nofile | r # | 0d_ | diffthis
63                \ | wincmd p | diffthis
64
65" use cscope if available
66if has("cscope") && filereadable("/usr/bin/cscope")
67   set csprg=/usr/bin/cscope
68   set csto=0
69   set cst
70   set nocsverb
71   " add any database in current directory
72   if filereadable("cscope.out")
73      cs add cscope.out
74   " else add database pointed to by environment
75   elseif $CSCOPE_DB != ""
76      cs add $CSCOPE_DB
77   endif
78   set csverb
79endif
80
81" Only do this part when compiled with support for autocommands.
82if has("autocmd")
83
84  " Enable file type detection.
85  " Use the default filetype settings, so that mail gets 'tw' set to 72,
86  " 'cindent' is on in C files, etc.
87  " Also load indent files, to automatically do language-dependent indenting.
88  filetype plugin indent on
89
90  " prevent duplication of autocommands
91  if !exists("autocommands_loaded")
92    let autocommands_loaded = 1
93
94    " For all text files set 'textwidth' to 78 characters.
95    autocmd FileType text setlocal textwidth=78
96
97    " When editing a file, always jump to the last known cursor position.
98    " Don't do it when the position is invalid or when inside an event handler
99    " (happens when dropping a file on gvim).
100    autocmd BufReadPost *
101      \ if line("'\"") > 0 && line("'\"") <= line("$") |
102      \ exe "normal g`\"" |
103      \ endif
104
105    " indent style used by subversion authors
106    au BufNewFile,BufRead ~/work/subversion/**/*.[ch]
107      \ setlocal cinoptions={.5s,:.5s,+.5s,t0,g0,^-2,e-2,n-2,p2s,(0,=.5s
108      \ formatoptions=croql cindent shiftwidth=4 tabstop=8
109
110    " use git styles for git commit message
111    au BufNewFile,BufRead COMMIT_EDITMSG set filetype=gitcommit
112
113    " load personal commands for all files
114    au BufEnter * runtime! my/*.vim
115
116  endif
117else " no autocmd
118
119  set autoindent "always set autoindenting on
120
121endif " autocmd
122

Archive Download this file

Branches:
master