summaryrefslogtreecommitdiff
path: root/vimrc
diff options
context:
space:
mode:
authorjohannst <stoelp@eit.uni-kl.de>2017-07-04 22:34:45 +0200
committerjohannst <stoelp@eit.uni-kl.de>2017-07-04 22:34:45 +0200
commita16dfdb7ba623a6907b8c082596ac3d58585f9b6 (patch)
tree274fdce41a37bc65b145f4d808cf8641188f3fe4 /vimrc
parentfe6f40c0bb36a6b53bada98352e79364abce067e (diff)
downloaddotfiles-a16dfdb7ba623a6907b8c082596ac3d58585f9b6.tar.gz
dotfiles-a16dfdb7ba623a6907b8c082596ac3d58585f9b6.zip
vimrc sandbox: added command to remove c-style commands
Diffstat (limited to 'vimrc')
-rw-r--r--vimrc33
1 files changed, 33 insertions, 0 deletions
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
"}}}