-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.vimrc
243 lines (196 loc) · 6.98 KB
/
.vimrc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
" To use it, copy it to
" for Unix and OS/2: ~/.vimrc
" for Amiga: s:.vimrc
" for MS-DOS and Win32: $VIM\_vimrc
" for OpenVMS: sys$login:.vimrc
" When started as "evim", evim.vim will already have done these settings.
if v:progname =~? "evim"
finish
endif
if has("gui_running")
colorscheme koehler
endif
" Use Vim settings, rather then Vi settings (much better!).
" This must be first, because it changes other options as a side effect.
set nocompatible
" https://github.com/tpope/vim-pathogen
call pathogen#infect()
" allow backspacing over everything in insert mode
set backspace=indent,eol,start
if has("vms")
set nobackup " do not keep a backup file, use versions instead
else
set backup " keep a backup file
endif
set history=100 " keep 100 lines of command line history
set ruler " show the cursor position all the time
set showcmd " display incomplete commands
set incsearch " do incremental searching
" For Win32 GUI: remove 't' flag from 'guioptions': no tearoff menu entries
" let &guioptions = substitute(&guioptions, "t", "", "g")
" Don't use Ex mode, use Q for formatting
map Q gq
" navigate split windows with ALT + Arrows
nmap <A-Down> <C-W><C-J>
nmap <A-Up> <C-W><C-K>
nmap <A-Right> <C-W><C-L>
nmap <A-Left> <C-W><C-H>
" More natural split opening
set splitbelow
set splitright
" This is an alternative that also works in block mode, but the deleted
" text is lost and it only works for putting the current register.
"vnoremap p "_dp
" Modern terminals support 256 colors, but sometimes you need to kick Vim to
" recognize this
if $TERM == "xterm-256color" || $TERM == "screen-256color" || $COLORTERM == "gnome-terminal"
set t_Co=256
endif
" Switch syntax highlighting on, when the terminal has colors
" Also switch on highlighting the last used search pattern.
if &t_Co > 2 || has("gui_running")
syntax on
set hlsearch
endif
" Create unexisting directories on save
" http://stackoverflow.com/questions/4292733/vim-creating-parent-directories-on-save
function s:MkNonExDir(file, buf)
if empty(getbufvar(a:buf, '&buftype')) && a:file!~#'\v^\w+\:\/'
let dir=fnamemodify(a:file, ':h')
if !isdirectory(dir)
call mkdir(dir, 'p')
endif
endif
endfunction
augroup BWCCreateDir
autocmd!
autocmd BufWritePre * :call s:MkNonExDir(expand('<afile>'), +expand('<abuf>'))
augroup END
" Only do this part when compiled with support for autocommands.
if has("autocmd")
" Enable file type detection.
" Use the default filetype settings, so that mail gets 'tw' set to 72,
" 'cindent' is on in C files, etc.
" Also load indent files, to automatically do language-dependent indenting.
filetype plugin indent on
" Put these in an autocmd group, so that we can delete them easily.
augroup vimrcEx
au!
" For all text files set 'textwidth' to 78 characters.
"autocmd FileType text setlocal textwidth=78
" When editing a file, always jump to the last known cursor position.
" Don't do it when the position is invalid or when inside an event handler
" (happens when dropping a file on gvim).
autocmd BufReadPost *
\ if line("'\"") > 0 && line("'\"") <= line("$") |
\ exe "normal g`\"" |
\ endif
augroup END
else
set autoindent " always set autoindenting on
endif " has("autocmd")
" Per fer mes llegible la lletra, x quan tens el fons negre
set background=dark
" Espais que ha de fer al apretar la tecla TAB
set tabstop=4
" Espais que ha de fer l'auto-indent (quan escrius codi)
set shiftwidth=2
" Fes espais en comptes de tabuladors
set expandtab
" Auto-timestamp
" let timestamp_regexp = '\v\C%((<Last %([cC]hanged?|[Mm]odified):\s+)|(\* \@version\s+))@<=.*$'
let timestamp_regexp = '\v\C%((<[Uu]ltim[a]* %([cC]anvi?|[Mm]odificacio):\s+)|(\* \@version\s+)|([Ll]ast [Cc]hanged: ))@<=.*$'
set modelines=20
set title
set autochdir
"if has('unnamedplus')
" set clipboard^=unnamed,unnamedplus
"else
" set clipboard^=unnamed
"endif
set clipboard=unnamed
" ignorecase plus smartcase make searches case-insensitive except when you
" include upper-case characters
set ignorecase
set smartcase
" powerline
" gap on arrow https://github.com/Lokaltog/powerline/issues/359
" in gitconfig set color=auto to solve branch display issues
set rtp+=~/.vim/bundle/powerline/powerline/bindings/vim
set laststatus=2
set noshowmode " Hide the default mode text (e.g. -- INSERT -- below the statusline)
" escape insert mode immediately
if ! has('gui_running')
set ttimeoutlen=10
augroup FastEscape
autocmd!
au InsertEnter * set timeoutlen=0
au InsertLeave * set timeoutlen=1000
augroup END
endif
" cometes en mode visual block, :help VISUAL
vmap " <Esc>`>a"<Esc>hlx`<i"<Esc>hlx
vmap f <Esc>`>a'.t %>><Esc>hlx`<i<%= ''<Esc>hlx
"vmap f <Esc>`>a' %><Esc>`<i<%= t '<Esc>
vmap g <Esc>`>a' %><Esc>`<hhi<%= t '<Esc>
vmap V <Esc>`>a') <Esc>hlx`<i T_(''<Esc>hlx
" next/previous buffer
:nmap <C-n> :bnext<CR>
:nmap <C-b> :bprev<CR>
:nmap , :CtrlPBuffer<CR>
" tabs
:nmap <S-Right> :tabnext<CR>
:nmap <S-Left> :tabprev<CR>
" file navigation
:nmap <C-a> :NERDTreeToggle<CR>
let NERDTreeQuitOnOpen = 1
" gitgutter
set signcolumn=yes
set updatetime=100
" https://github.com/airblade/vim-gitgutter/issues/696
highlight! link SignColumn LineNr
autocmd ColorScheme * highlight! link SignColumn LineNr
" ignores pel CtrlP
let g:ctrlp_custom_ignore = {
\ 'dir': 'node_modules$\|build$\|tmp$\|files$\|coverage$',
\ 'file': '\~$'
\ }
" max files pel CtrlP
let g:ctrlp_max_files=0
"let g:ctrlp_max_depth=100
" https://stackoverflow.com/questions/21010029
" amagar backups a l'explorador
let g:netrw_list_hide= '.*\.swp$,\~$$'
" Treure el destacat actual a l'apretar espai, per exemple al cercar
:nnoremap <silent> <Space> :nohlsearch<Bar>:echo<CR>
" amaga els comentaris, zo per obrirlos i zc per tancar-los
"set fdm=expr
"set fde=getline(v:lnum)=~'^\\s*#'?1:getline(prevnonblank(v:lnum))=~'^\\s*#'?1:getline(nextnonblank(v:lnum))=~'^\\s*#'?1:0
" completar fitxers com al shell
set wildmode=longest,list:longest,list:full
" vimdiff: ignore spaces
set diffopt+=iwhite
" vimdiff: colors
if &diff
" colorscheme jellybeans
" colorscheme custom
" colorscheme evening
highlight DiffAdd cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffDelete cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffChange cterm=bold ctermfg=10 ctermbg=17 gui=none guifg=bg guibg=Red
highlight DiffText cterm=bold ctermfg=10 ctermbg=88 gui=none guifg=bg guibg=Red
endif
" Make lines with linter errors readable
highlight SpellBad ctermfg=0
highlight SpellBad ctermbg=3
" Match all forms of brackets in pairs (including angle brackets)
set matchpairs=(:),{:},[:],<:>
" If the Vim buffer for a file doesn't have any changes and Vim detects the
" file has been altered, quietly update it
set autoread
if exists("did_load_filetypes")
finish
endif
augroup filetypedetect
au! BufRead,BufNewFile *.pp setfiletype puppet
augroup END