-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path_vimrc
229 lines (184 loc) · 6.68 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
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" pathogen setup
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
call pathogen#infect()
call pathogen#helptags()
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Setup items offered by default installation for Windows Vim
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" No compatibility with VI
set nocompatible
source $VIMRUNTIME/vimrc_example.vim
"source $VIMRUNTIME/mswin.vim
"behave mswin
set diffexpr=MyDiff()
function MyDiff()
let opt = '-a --binary '
if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
let arg1 = v:fname_in
if arg1 =~ ' ' | let arg1 = '"' . arg1 . '"' | endif
let arg2 = v:fname_new
if arg2 =~ ' ' | let arg2 = '"' . arg2 . '"' | endif
let arg3 = v:fname_out
if arg3 =~ ' ' | let arg3 = '"' . arg3 . '"' | endif
let eq = ''
if $VIMRUNTIME =~ ' '
if &sh =~ '\<cmd'
let cmd = '""' . $VIMRUNTIME . '\diff"'
let eq = '"'
else
let cmd = substitute($VIMRUNTIME, ' ', '" ', '') . '\diff"'
endif
else
let cmd = $VIMRUNTIME . '\diff'
endif
silent execute '!' . cmd . ' ' . opt . arg1 . ' ' . arg2 . ' > ' . arg3 . eq
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" My personal setup using default commands/values in VIM
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Tab
set tabstop=4
set shiftwidth=4
set expandtab
" makes the spaces feel like real tabs
set softtabstop=4
" Search
set ignorecase
set smartcase
set hlsearch
set incsearch
" Indent
set ai
" Show line number
set number
" Highlight current line
set cursorline
" Use highlight syntax
" syntax off
" No compatibility with VI
set nocompatible
" Enable filetype detection and loads 'ftplugin.vim'
" http://vimdoc.sourceforge.net/htmldoc/filetype.html
filetype plugin on
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugin related setup
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Color scheme
" colorscheme zenburn
set background=dark
colorscheme solarized
" Automatically justify table with | using tabular plugin
" From https://gist.github.com/287147
inoremap <silent> <Bar> <Bar><Esc>:call <SID>align()<CR>a
function! s:align()
let p = '^\s*|\s.*\s|\s*$'
if exists(':Tabularize') && getline('.') =~# '^\s*|' && (getline(line('.')-1) =~# p || getline(line('.')+1) =~# p)
let column = strlen(substitute(getline('.')[0:col('.')],'[^|]','','g'))
let position = strlen(matchstr(getline('.')[0:col('.')],'.*|\s*\zs.*'))
Tabularize/|/l1
normal! 0
call search(repeat('[^|]*|',column).'\s\{-\}'.repeat('.',position),'ce',line('.'))
endif
endfunction
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Plugin related setup: requires external program
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" To use LanguageTool for grammar checking
let g:languagetool_jar="e:/My_Program_Files/LanguageTool-2.1/languagetool-commandline.jar"
let g:languagetool_lang="en-US"
" EasyAlign
" For visual mode (e.g. vip<Enter>)
vmap <Enter> <Plug>(EasyAlign)
" For normal mode, with Vim movement (e.g. <Leader>aip)
nmap <Leader>a <Plug>(EasyAlign)
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Shortcuts
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" To create markdown level 1 and level 2 header
nnoremap <leader>h1 yypVr=
nnoremap <leader>h2 yypVr-
" Clear search terms
nnoremap <leader>cst :let @/ = ""<cr>
" Clear all trailing white spaces
" From http://stevelosh.com/blog/2010/09/coming-home-to-vim/
nnoremap <leader>W :%s/\v\s+$//<cr>:let @/ = ""<cr>
" Use 'magic' for search always
" From http://stevelosh.com/blog/2010/09/coming-home-to-vim/
nnoremap / /\v
vnoremap / /\v
" Move by screen line
nnoremap j gj
nnoremap k gk
vnoremap j gj
vnoremap k gk
" Add blank line
" http://vim.wikia.com/wiki/Insert_newline_without_entering_insert_mode
" nnoremap <S-Enter> O<Esc>j
" nnoremap <CR> o<Esc>k
nnoremap <S-Enter> O<Esc>
nnoremap <CR> o<Esc>
" Use space and backspace to navigate by 10 lines
" http://zuttobenkyou.wordpress.com/2011/02/15/some-thoughts-on-emacs-and-vim/
nnoremap <space> 10jzz
nnoremap <backspace> 10kzz
nnoremap <S-space> 10kzz
" showmarks plugin
" Do not display automatically set marks
" http://stackoverflow.com/questions/8720313/show-marks-plugin-causes-marks-to-pop-in-after-around-4-seconds
let showmarks_include = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
" http://vimcasts.org/episodes/show-invisibles/
" Shortcut to rapidly toggle `set list`
nmap <leader>l :set list!<CR>
" Use the same symbols as TextMate for tabstops and EOLs
set listchars=tab:?\ ,eol:¬
" Select visual block again after decreasing or increasing indent
vnoremap < <gv
vnoremap > >gv
" Replace extended ASCII characters by similar looking ASCII code
function! ToAscii()
:silent! %s/\%x91/'/g
:silent! %s/\%x92/'/g
:silent! %s/\%x93/"/g
:silent! %s/\%x94/"/g
:silent! %s/\%x95/ - /g
:silent! %s/\%x96/-/g
:silent! %s/\%x97/--/g
:silent! %s/\%x85/.../g
endfunction
nnoremap <silent> <leader>ta :call ToAscii()<CR>
" Script to convert Test bank to latex form
function! MakeMultipleChoice()
:silent! call ToAscii()<CR>
:silent! g/^\s*$/d
:silent! :1
:silent! normal I\question
:silent! g/\v^a./normal O\begin{choices}
:silent! g/\v^e./normal o\end{choices}
:silent! %s/\v^[abcde]./ \\choice/g
:silent! %s/\v\$/\\$/g
:silent! %s/\v\&/\\&/g
:silent! %s/\v\%/\\%/g
:silent! %s/\v_+/\\blankplaceholder/g
:silent! :retab
:silent! normal Go
endfunction
nnoremap <silent> <leader>mmc :call MakeMultipleChoice()<CR>
" Script to make pipe table header similar to EMACS org-mode
function! MakePipeTableHeader()
:silent! normal yyp
:silent! s/\v[^\|]/-/g
:silent! s/\v-\|-/-+-/g
endfunction
nnoremap <silent> <leader>mth :call MakePipeTableHeader()<CR>
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" Selectively load spell checker for some file types
" http://jhshi.wordpress.com/2012/11/05/enabledisable-spell-checking-according-to-file-type-in-vim/
""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
" global setting
set nospell
" local
au BufNewFile,BufRead,BufEnter *.tex setlocal spell spelllang=en_us
au BufNewFile,BufRead,BufEnter *.txt setlocal spell spelllang=en_us
au BufNewFile,BufRead,BufEnter *.md setlocal spell spelllang=en_us