-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdot_vimrc
More file actions
205 lines (155 loc) · 5.47 KB
/
dot_vimrc
File metadata and controls
205 lines (155 loc) · 5.47 KB
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
" **** NOTE: Unused legacy Vim configuration ****
" -----------------
" SJR customisation
" -----------------
" Don't need vi compatibility.
set nocompatible
" Set <Leader> character.
let mapleader = ","
set encoding=utf-8
set directory=~/.vim/swap// "swap files
set backup
set backupdir=$HOME/.vim/backups//
set undofile
set undodir=$HOME/.vim/undo
if has("gui_running")
colorscheme desert
highlight Normal guibg=grey15
set guifont=Monospace\ 10
set guioptions-=m "remove menu bar
set guioptions-=T "remove toolbar
set guioptions-=r "remove right-hand scroll bar
" gx command opens URI under cursor in browser.
" See http://vi.stackexchange.com/questions/5032/gx-not-opening-url-in-gvim-but-works-in-terminal
"let g:netrw_browsex_viewer="setsid xdg-open"
" Use standard Windows functions for Ctrl+C, Ctrl+V, Ctrl+X, Ctrl+S,
" Ctrl+A, Ctrl+Tab, Ctrl+F4 etc.
" Only seems to work with gvim.
source $VIMRUNTIME/mswin.vim
behave mswin
endif
" vim-plug plugin management
call plug#begin('~/.vim/plugged')
" Declare plugins
Plug 'junegunn/vim-plug'
Plug 'jlanzarotta/bufexplorer'
let g:polyglot_disabled = ['markdown'] "markdown is incompatible with rimu syntax
Plug 'sheerun/vim-polyglot'
Plug 'editorconfig/editorconfig-vim'
Plug 'farmergreg/vim-lastplace'
call plug#end()
" Show command parameters on status line.
set showcmd
" Always keep a couple of lines above and below the cursor.
set scrolloff=2
" Mainly to suppress beeping under Windows.
set visualbell
" Intelligent case-sensitive search (ignorecase must be set for smartcase to
" work).
set ignorecase
set smartcase
" Replace all occurences on line by default (use g flag to replace the first).
"set gdefault
" Highlight search result as you type.
set incsearch
set showmatch
set hlsearch
set ruler
" Specify what to save in ~/.viminfo
set viminfo='1000,h,!,:500,@500,/500
" Optimize colors for dark background (overrides default auto sense).
set background=dark
" Highlight search in red.
hi Search term=reverse ctermfg=white ctermbg=red guifg=white guibg=Red
" Disable folding.
set nofoldenable
" So buffers can be switched without having to save first.
set hidden
" No insert mode backspace/delete boundaries.
set backspace=indent,eol,start
syntax on
filetype on
filetype indent on
filetype plugin on
" Show tabs and trailing characters.
"set listchars=tab:»·,trail:·,eol:¬
set listchars=tab:»·,trail:·
set list
" If we don't do this spaces are highlighted in the margin of changelog files.
let g:changelog_spacing_errors = 0
" I prefer to return to the column rather than start of line.
nnoremap '' ``
nnoremap ' `
" Space to page down like most browsers.
" nnoremap <Space> <PageDown>
" Make line title case
nnoremap gt :s/\<\(\w\)\(\w*\)\>/\u\1\L\2/g<CR>
" Turn off search and spelling highlights.
nnoremap <Leader><space> :nohls<CR>:set nospell<CR>
" Highlight all occurrences of word under the cursor.
nnoremap <Leader>h :let @/=expand("<cword>")<CR>:set hls<CR>
" Spell checking on.
nnoremap <Leader>s :set spell<CR>
" Go to next spelling error.
nnoremap <Leader>d ]s
" Make spelling suggestion for word under the cursor.
nnoremap <Leader>D z=
" Reformat paragraphs and list.
nnoremap <Leader>r gq}
nnoremap <C-R> gq}
nnoremap Q gq}
" Undo.
nnoremap U :redo<CR>
" Expand tabs to spaces and delete trailing white space and Dos-returns.
nnoremap <Leader>t :set et<CR>:retab!<CR>:silent! %s/[\r \t]\+$//<CR>
" Retab text and delete trailing white space and Dos-returns.
nnoremap <Leader>T :set noet<CR>:retab!<CR>:set et<CR>:silent! %s/[\r \t]\+$//<CR>
" Save all
nnoremap <Leader>w :wa<CR>
" Save all and exit
nnoremap <Leader>q :xa<CR>
" Close buffer
nnoremap <Leader>c :bd<CR>
" Paste toggle.
nnoremap <Leader>v :set invpaste<CR>
" Toggle to previous buffer.
nnoremap <Leader>, <C-^>
nnoremap <C-Tab> <C-^>
" Latin long vowels.
imap <Leader>a ā
imap <Leader>e ē
imap <Leader>i ī
imap <Leader>o ō
imap <Leader>u ū
" Buffer Explorer.
nnoremap <silent> <Leader>f :BufExplorer<CR>
" Auto-save when gvim loses focus (NOTE: Does not work with terminal Vim).
autocmd FocusLost * silent! wall
" Highlight wrapped lines. But it spoils terminal cut-and-paste so need to
" explicitly unset all the subsequently set on a per buffer basis.
autocmd BufEnter * set showbreak=
" Default tab expansion and tab stops.
autocmd BufRead,BufNewFile *
\ setlocal autoindent expandtab tabstop=8 softtabstop=2 shiftwidth=2
" Specific tab stops and options.
autocmd BufRead,BufNewFile *.rmu,*.txt,README,TODO,CHANGELOG,NOTES,ABOUT
\ setlocal textwidth=70 wrap formatoptions+=t
\ formatlistpat=^\\s*\\d\\+\\.\\s\\+\\\\|^\\s*[a-zA-Z.]\\.\\s\\+\\\\|^\\s*[ivxIVX]\\+\\.\\s\\+
autocmd BufRead,BufNewFile *.{cs,c,h,cc,py,php,go}
\ setlocal softtabstop=4 shiftwidth=4
autocmd BufRead,BufNewFile *.{sh,zsh},.bashrc,bash_profile,.zshrc
\ setlocal softtabstop=4 shiftwidth=4
autocmd BufRead,BufNewFile *.{groovy,gradle,gant,java,kt,kts}
\ setlocal softtabstop=4 shiftwidth=4
" File type exceptions.
autocmd BufRead,BufNewFile Jakefile setlocal filetype=javascript
autocmd BufRead,BufNewFile *.md setlocal syntax=rimu
autocmd BufRead,BufNewFile *.rmu setlocal filetype=rimu
autocmd BufRead,BufNewFile *.txt setlocal filetype=asciidoc
autocmd BufNewFile,BufRead *.gradle,*.gant setlocal filetype=groovy
if has("gui_running")
" Session auto load and save.
autocmd VimEnter * nested :source $HOME/.vim/sessions/default
set sessionoptions+=winpos,resize
autocmd VimLeave * :mksession! $HOME/.vim/sessions/default
endif