-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path.vimrc
218 lines (164 loc) · 4.87 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
" my .vimrc
"
" author: Yu-Jie Lin
" web : https://github.com/livibetter/dotfiles/blob/master/vimrc
"
" note: if you know any way to improve this file, please open an issue on
" GitHub or contact me via http://s.yjl.im/contact
"=========="
" Settings "
"=========="
colorscheme desert
" Others
"========
" no intro message
set shortmess+=I
set hidden
" Save buffer list
set viminfo='20,\"500,%
set autoindent
set tabstop=8
set softtabstop=4
set expandtab
set smarttab
set shiftwidth=4
set textwidth=0
set mouse=a
set ttymouse=xterm2
set sessionoptions=blank,buffers,curdir,folds,help,resize,tabpages,winsize
set pastetoggle=<F12>
set modeline
set dictionary-=/usr/share/dict/words dictionary+=/usr/share/dict/words
"============="
" keymappings "
"============="
mapclear
let mapleader = ","
" Easy way out from insert mode
imap <C-j> <Esc>
imap <F3> <ESC>:set hlsearch! hlsearch?<CR><INSERT><RIGHT>
nmap <F3> :set hlsearch! hlsearch?<CR>
imap <F4> <C-R>=strftime("%FT%TZ", localtime()-8*3600)<CR>
nmap <F4> "=strftime("%FT%TZ", localtime()-8*3600)<CR>p
" Spell check
imap <F7> <ESC>:setlocal spell! spelllang=en_us<CR>
nmap <F7> <ESC>:setlocal spell! spelllang=en_us<CR>
" For setting current directory
nnoremap <LEADER> cd : cd %:p:h<CR>:pwd<CR>
nnoremap <LEADER>lcd :lcd %:p:h<CR>:pwd<CR>
" For reload vimrc quick
nmap <LEADER>ev :tabnew ~/.vimrc<CR>
nmap <LEADER>rv :source ~/.vimrc<CR>
" Buffers
nmap <LEADER>ls :ls<CR>
nmap <LEADER>bp :bp<CR>
nmap <LEADER>bn :bn<CR>
nmap <LEADER>bw :bw<CR>
nmap <LEADER>bb :b#<CR>
nmap <LEADER>b# :b#<CR>
" Clipboard
nmap <LEADER>y "+y
nmap <LEADER>Y "+yy
nmap <LEADER>p "+p
nmap <LEADER>P "+P
"============"
" some stuff "
"============"
augroup fixes
autocmd!
autocmd BufEnter * lcd %:p:h
" Set shell title
" http://vim.wikia.com/wiki/Automatically_set_screen_title
"==========================================================
autocmd BufEnter * let &titlestring = 'vim:' . expand('%:t')
if &term =~ '\(st\|xterm\).*'
set title
endif
" Markdown
"==========
autocmd BufRead *.md,*.mkd set filetype=markdown
" fenced code block
autocmd BufRead * if &filetype == 'markdown'
\ | syn region markdownCode matchgroup=markdownCodeDelimiter
\ start="``` \="
\ end=" \=```" keepend contains=markdownLineStart
\ | endif
" W
" =
" Only text files and files without extensions under ~/Document/w.txt
autocmd BufRead *
\ if &filetype == 'text'
\ || ( &filetype != 'gitcommit'
\ && expand('%:e') == ''
\ && expand('%:p:h') =~ expand('$HOME') . '/Documents/w.txt'
\ )
\ | let &l:textwidth = 79
\ | let &l:colorcolumn = &textwidth + 1
\ | setlocal formatoptions=qwa2t
\ | setlocal spell spelllang=en_us
\ | hi ColorColumn ctermbg=lightgrey guibg=lightgrey
\ | endif
augroup END
"================================================="
" boxes comments <http://boxes.thomasjensen.com/> "
"================================================="
augroup boxes
autocmd!
autocmd BufRead .boxes,boxes-config set filetype=boxes
autocmd BufRead * call BoxesMap()
augroup END
function! BoxesMap()
if &filetype =~ '^\(boxes\|conf\|make\|python\|sh\)$'
let boxestype = 'pound'
elseif &filetype =~ '^\(c\|css\|javascript\)$'
let boxestype = 'c'
elseif &filetype =~ 'vim\|pentadactyl'
let boxestype = 'vim'
else
return
endif
for [key, type] in [['a', 'h1'] , ['b', 'h2'], ['c', 'cmt']]
let t = type . '-' . boxestype
for [keypx, optr] in [['c', ''], ['C', ' -r']]
let k = keypx . key
for maptype in ['nmap', 'vmap']
let m = ':' . maptype . ' <buffer> <LEADER>'
exec m . k . ' !!boxes -d ' . t . optr . '<CR>'
exec m . k . ' !boxes -d ' . t . optr . '<CR>'
endfor
endfor
endfor
endfunction
"===================================="
" https://github.com/xolox/vim-notes "
"===================================="
let g:notes_directories = ['~/Documents/VimNotes']
let g:notes_tagsindex = '~/Documents/VimNotes/tags.txt'
let g:notes_conceal_italic = 0
let g:notes_conceal_bold = 0
let g:notes_conceal_url = 0
nmap <LEADER>todo :Note ToDo<CR>
" using command-line-only abbrev to alias Note
cabbrev note Note
" ================================================================== "
" Open fold navigation "
" Based on: http://vim.wikia.com/wiki/Navigate_to_the_next_open_fold "
" ================================================================== "
function! GoToOpenFold(direction)
if (a:direction == "next")
normal zj
let start = line('.')
while (foldclosed(start) != -1)
let start = start + 1
endwhile
else
normal zk
let start = line('.')
while (foldclosed(start) != -1)
let start = start - 1
endwhile
endif
call cursor(start, 0)
endfunction
nmap zJ :call GoToOpenFold("next")<CR>
nmap zK :call GoToOpenFold("prev")<CR>