diff options
Diffstat (limited to 'vim.dot.link/plugin/lib.vim')
-rw-r--r-- | vim.dot.link/plugin/lib.vim | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/vim.dot.link/plugin/lib.vim b/vim.dot.link/plugin/lib.vim new file mode 100644 index 0000000..1c3212e --- /dev/null +++ b/vim.dot.link/plugin/lib.vim @@ -0,0 +1,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() +" }}} |