From a16dfdb7ba623a6907b8c082596ac3d58585f9b6 Mon Sep 17 00:00:00 2001 From: johannst Date: Tue, 4 Jul 2017 22:34:45 +0200 Subject: vimrc sandbox: added command to remove c-style commands --- vimrc | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/vimrc b/vimrc index 742baa1..4b19f14 100644 --- a/vimrc +++ b/vimrc @@ -538,6 +538,39 @@ if s:sandbox_enable " when opening file (of given filetype? maybe start with c/c++) create copy in this file in file_path/.bak/file_name " filter file creation somehow, that it does not try to create backups when opening for example /usr/include/*.h + function! s:LineClearPureBlank() + execute 'silent! %s#\m^\s\+$##g' + endfunction + function! s:LineClearTrailingBlank() + execute 'silent! %s#\m\s\+$##g' + endfunction + function! s:ReduceConsecutiveEmptyLines() + execute 'silent! %s/\m\(^\n\)\+/\r/g' + endfunction + + "function! s:LineDeleteCStyleComment() + "execute 'silent! g#\m^\s\{-}//#d' + "endfunction + + function! s:LineClearCStyleComment() + execute 'silent! %s#\m\(.\{-\}\)//.*#\1#g' + endfunction + + function! s:BlockClearCStyleComment() + " hack to keep copyright header + execute 'silent! 2,$s#\m\s\{-\}\/\*[[:alnum:][:blank:][:graph:]\n]\{-\}\*\/\s*##g' + "execute 'silent! %s#\m^\/\*[[:alnum:][:blank:][:graph:]\n]\{-\}\*\/##g' + endfunction + + function! s:RemoveCStyleComments() + call s:LineClearCStyleComment() + call s:BlockClearCStyleComment() + call s:LineClearPureBlank() + call s:LineClearTrailingBlank() + call s:ReduceConsecutiveEmptyLines() + endfunction + command! CC call s:RemoveCStyleComments() + endif "}}} -- cgit v1.2.3