aboutsummaryrefslogtreecommitdiff
path: root/vim.dot.link/plugin/lib.vim
blob: f1b2a3083eac4500df5b81eb5669b968297f8462 (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
" 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()
" }}}