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