-
Notifications
You must be signed in to change notification settings - Fork 0
/
vimrc
288 lines (235 loc) · 8.41 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
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
if has('win32') || has('win64')
set runtimepath=$HOME/.vim,$VIM/vimfiles,$VIMRUNTIME,$VIM/vimfiles/after,$HOME/.vim/after
endif
execute pathogen#infect()
"":imap jk <Esc>
"":imap kj <Esc>
"" Stop the cursor from moving left when exiting insert mode
set timeoutlen=300
inoremap jk x<C-c>"_x
inoremap kj x<C-c>"_x
"I have no memory of adding this key.
:imap <c-@> .<enter>
"Make searches better
set ignorecase
set smartcase
"Move lines or text blocks with c-j amd c-k
"Moving Lines - VimTricks
"https://vimtricks.com/p/vimtrick-moving-lines/
nnoremap <c-j> :m .+1<CR>==
nnoremap <c-k> :m .-2<CR>==
inoremap <c-j> <Esc>:m .+1<CR>==gi
inoremap <c-k> <Esc>:m .-2<CR>==gi
vnoremap <c-j> :m '>+1<CR>gv=gv
vnoremap <c-k> :m '<-2<CR>gv=gv
"Derek Sivers tip, write each line separately. Markdown doesn't care about
"single returns. Two spaces in a row add a . and a return
autocmd FileType markdown imap <space><space> .<enter>
"autocmd FileType md imap @@| .<enter>
"Current date and time for journal
iab <expr> dts strftime("%Y/%m/%d %H:%M -")
"Run scripts directly, it also saves them before running. You may not want
"them to automatically save though
nnoremap <leader>r :w<enter>:!"%:p"<enter>
let g:move_key_modifier = 'C'
let maplocalleader="\\"
" [plasticboy/vim\-markdown: Markdown Vim Mode](https://github.com/plasticboy/vim-markdown)
let g:vim_markdown_auto_extension_ext = 'markdown'
" Fold on header 1
let g:vim_markdown_folding_level = 2
let g:vim_markdown_folding_disabled = 1
let g:vim_markdown_conceal = 0
" Follow links to edit a file with `ge`
"let g:vim_markdown_no_extensions_in_markdown = 1
" Shrink the table of contents"
let g:vim_markdown_toc_autofit = 1
""let g:vim_markdown_folding_disabled = 1
let @r = ""
"Turn on distraction free writing. Works great with full screen terminals
noremap <c-g> :Goyo<CR>
imap <c-g> <C-O><c-g>
"Browser files on the right
let g:NERDTreeWinPos = "right"
map <C-n> :NERDTreeToggle<CR>
nnoremap <leader>b :buffers<CR>:buffer<space>
" Zoom splits
" [Zooming Vim Window Splits Like a Pro](https://medium.com/@vinodkri/zooming-vim-window-splits-like-a-pro-d7a9317d40)
noremap Zz <c-w>_ \| <c-w>\|
noremap Zo <c-w>=
" Configure taskpaper
let g:task_paper_follow_move = 0
nnoremap <buffer> <silent> <Leader>tq
\ :<C-u>call taskpaper#add_tag('priority')<CR>
nnoremap <buffer> <silent> <Leader>tQ
\ :<C-u>call taskpaper#delete_tag('priority', '')<CR>
" Trigger configuration. Do not use <tab> if you use https://github.com/Valloric/YouCompleteMe.
let g:UltiSnipsExpandTrigger="<tab>"
""let g:UltiSnipsJumpForwardTrigger="<c-j>"
""let g:UltiSnipsJumpBackwardTrigger="<c-k>"
" Set UltiSnipsFolder"
let g:UltiSnipsSnippetDirectories = ['~/.vim/UltiSnips', 'UltiSnips']
let g:UltiSnipsEditSplit="vertical"
" Some security features
" Change default encryption
" First make sure nothing is written to ~/.viminfo while editing
" an encrypted file.
autocmd BufReadPre,FileReadPre *.x set viminfo=
autocmd BufReadPre,FileReadPre *.x set noswapfile
set cm=blowfish
" If the current buffer has never been saved, it will have no name,
" call the file browser to save it, otherwise just save it.
""command -nargs=0 -bar Update if &modified
"" \| if empty(bufname('%'))
"" \| browse confirm write
"" \| else
"" \| confirm write
"" \| endif
"" \|endif
""imap wq <Esc>:Update<CR>
syntax on
set number
"set nowrap
set ruler
""set colorcolumn=80
""startinsert
set directory=~/tmp//,/var/tmp//,/tmp//,.
" Autosave taskpaper files
" Plugin 'plugin/vim-auto-save'
" Plugin 'djoshea/vim-autoread'
" let g:auto_save_events = ["InsertLeave", "TextChanged"]"
let g:auto_save_events = ["CursorHold", "CursorHoldI"]
"Automatically save todo, taskpape, and markdown files while editing
autocmd filetype todo let g:auto_save = 1
autocmd filetype todo :WatchForChanges!
autocmd filetype taskpaper let g:auto_save = 1
autocmd filetype taskpaper :WatchForChanges!
autocmd filetype markdown let g:auto_save = 1
autocmd filetype markdown :WatchForChanges!
if has('gui_running')
set background=dark
colorscheme solarized
"" set guifont=Source\ Code\ Pro:h14
set guifont=Consolas:h16:cANSI
set guioptions-=r "Don't show right scroll bar
set guioptions-=T "remove toolbar"
endif
""function! WordCount()
"" let s:old_status = v:statusmsg
"" let position = getpos(".")
"" exe ":silent normal g\"
"" let stat = v:statusmsg
"" let s:word_count = 0
"" if stat != '--No lines in buffer--'
"" let s:word_count = str2nr(split(v:statusmsg)[11])
"" let v:statusmsg = s:old_status
"" end
"" call setpos('.', position)
"" return s:word_count
""endfunction"
""
""function WordCount()
"" let s:old_status = v:statusmsg
"" exe "silent normal g\<c-g>"
"" let s:word_count = str2nr(split(v:statusmsg)[11])
"" let v:statusmsg = s:old_status
"" return s:word_count
""endfunction
""
""set mouse=a
"" Goyo for distraction free editing
function! s:goyo_enter()
silent !tmux set status off
silent !tmux list-panes -F '\#F' | grep -q Z || tmux resize-pane -Z
set noshowmode
set noshowcmd
set scrolloff=999
""Limelight
" ...
endfunction
function! s:goyo_leave()
silent !tmux set status on
silent !tmux list-panes -F '\#F' | grep -q Z && tmux resize-pane -Z
set showmode
set showcmd
set scrolloff=5
"Limelight!
" ...
endfunction
autocmd! User GoyoEnter nested call <SID>goyo_enter()
autocmd! User GoyoLeave nested call <SID>goyo_leave()
"" Set up for word processing Markdown files
function! WordProcessorMode()
iab xtime <c-r>=strftime("%H:%M:%S")<cr>
iab xdate <c-r>=strftime("%m/%d/%y %H:%M:%S")<cr>
let g:pencil#wrapModeDefault = 'soft'
""setlocal formatoptions=1
setlocal expandtab
setlocal tabstop=4
setlocal shiftwidth=4
map j gj
map k gk
setlocal spell spelllang=en_us
set thesaurus+=~/.vim/thesaurus/mthesaur.txt
set complete+=s
""setlocal wrap
""setlocal linebreak nolist
""setlocal foldcolumn=10
""set tw=72
setlocal nonumber
hi FoldColumn ctermbg=Black ctermfg=Black
call pencil#init()
""set statusline=%<%f\ %h%m%r%w\ \ %{PencilMode()}\ %=\ col\ %c%V\ \ line\ %l\,%L\ %P
""set rulerformat=%-12.(%l,%c%V%)%{PencilMode()}\ %P
""Goyo
endfunction
com! WP call WordProcessorMode()
filetype plugin indent on
""setlocal tabstop=4 shiftwidth=4 expandtab
set tabstop=4
set shiftwidth=4
set expandtab
au BufRead * normal zR
autocmd FileType p8 setlocal tabstop=1 shiftwidth=1 noexpandtab
autocmd FileType ruby setlocal tabstop=2 shiftwidth=2 expandtab
autocmd FileType python setlocal tabstop=4 shiftwidth=4 expandtab
autocmd FileType php setlocal tabstop=4 shiftwidth=4 expandtab omnifunc=phpcomplete#CompletePHP
""autocmd FileType markdown,md,rst setlocal formatoptions=ant textwidth=72 wrapmargin=0 foldcolumn=10 columns=100 nonumber
autocmd FileType markdown,md,rst WP
" Inform7
au BufNewFile,BufRead *.ni setf inform7
"Easier navigations of splits
""nnoremap <C-J> <C-W><C-J>
""nnoremap <C-K> <C-W><C-K>
""nnoremap <C-L> <C-W><C-L>
""nnoremap <C-H> <C-W><C-H>
""set splitbelow
""set splitright
highlight LineNr ctermfg=darkcyan ctermbg=black
highlight foldcolumn ctermbg=black
""set wrap linebreak nolist
""set tw=72
:abbr #b /************************************************
:abbr #e ************************************************/
""set rtp+=~/.local/lib/python2.7/site-packages/powerline/bindings/vim
" If the current buffer has never been saved, it will have no name,
" call the file browser to save it, otherwise just save it.
" You will probably have to do a:
" stty -ixon
" so the shell doesn't grab control s
command -nargs=0 -bar Update if &modified
\| if empty(bufname('%'))
\| browse confirm write
\| else
\| confirm write
\| endif
\|endif
nnoremap <silent> <C-S> :<C-u>Update<CR>
" highlight the status bar when in insert mode
" (https://github.com/chrishunt/dot-files/)
set laststatus=2
""if version >= 700
"" au InsertEnter * hi StatusLine term=reverse ctermbg=5 gui=undercurl guisp=Magenta
"" au InsertLeave * hi StatusLine term=reverse ctermfg=0 ctermbg=2 gui=bold,reverse
""endif
""
""au BufRead,BufNewFile * startinsert