blob: 1c3212e2b378fa093c9043f3136f0b36a8978a2f (
plain)
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
|
" lib.vim - Miscelaneous functions {{{
"
" Author: Silvio Rhatto <rhatto@riseup.net>
"
" Checkbox handling {{{
"
" This is commented out because vitalk/vim-simple-todo is being used instead.
"
" Thanks https://www.reddit.com/r/vim/comments/slqsao/readymade_solution_for_handling_markdown/
"function! ToggleCheckbox()
" let line = getline('.')
"
" if line =~ '- \[ \]'
" call setline('.', substitute(line, '- \[ \]', '- \[x\]', ''))
" elseif line =~ '- \[x\]'
" call setline('.', substitute(line, '- \[x\]', '- \[ \]', ''))
" elseif line =~ '- '
" call setline('.', substitute(line, '- ', '- \[ \] ', ''))
" endif
"endf
" }}}
" Remove trailing spaces {{{
"
" Thanks https://vi.stackexchange.com/a/456
fun! TrimWhitespace()
let l:save = winsaveview()
keeppatterns %s/\s\+$//e
call winrestview(l:save)
endfun
command! TrimWhitespace call TrimWhitespace()
" }}}
" Cleanup the buffer {{{
"
" Implement miscelaneous buffer cleansing procedures
function BufferCleansing()
" Trim white spaces
call TrimWhitespace()
endfunction
command! BufferCleansing call BufferCleansing()
" }}}
|