Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 14 additions & 9 deletions plugin/comments.vim
Original file line number Diff line number Diff line change
Expand Up @@ -83,14 +83,19 @@
" *********************************************************************************************
" Jasmeet Anand 11th January 2009 v2.12
" bug fix for haskel files as prpvided by Jean-Marie
" *********************************************************************************************
" Martin H. Thoresen 17th January 2015 v2.13
" Added support for Rust
" Incremented version number
" *********************************************************************************************
"

" Exit if already loaded
if exists("loaded_comments_plugin")
finish
endif

let loaded_comments_plugin="v2.10"
let loaded_comments_plugin="v2.13"

" key-mappings for comment line in normal mode
noremap <silent> <C-C> :call CommentLine()<CR>
Expand All @@ -109,8 +114,8 @@ function! CommentLine()
" for .cpp or .hpp or .java or .C files use //
if file_name =~ '\.cpp$' || file_name =~ '\.hpp$' || file_name =~ '\.java$' || file_name =~ '\.php[2345]\?$' || file_name =~ '\.C$'
execute ":silent! normal ^i//\<ESC>==\<down>^"
" for .c or .h or .pc or .css files use /* */
elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$'
" for .c or .h or .pc or .css or rs files use /* */
elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$'
" if there are previous comments on this line ie /* ... */
if stridx(getline("."), "\/\*") != -1 && stridx(getline("."), "\*\/") != -1
execute ":silent! normal :nohlsearch\<CR>:s/\\([^\\/\\*]*\\)\\(\\/\\*.*\\*\\/\\)/\\1\\*\\/\\2/\<CR>:s/\\([^[:blank:]]\\+\\)/\\/\\*\\1/\<CR>:nohlsearch\<CR>=="
Expand Down Expand Up @@ -178,8 +183,8 @@ function! UnCommentLine()
elseif file_name =~ '\.ml$' || file_name =~ '\.mli$'
execute ":silent! normal :nohlsearch\<CR>:s/(\\*//\<CR>:nohlsearch\<CR>"
execute ":silent! normal :nohlsearch\<CR>:s/\\*)//\<CR>:nohlsearch\<CR>=="
" for .c or .h or .pc or .css files use /* */
elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$'
" for .c or .h or .pc or .css or rs files use /* */
elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$'
execute ":silent! normal :nohlsearch\<CR>:s/\\/\\*//\<CR>:s/\\*\\///\<CR>:nohlsearch\<CR>=="
" for .vim files use "
elseif file_name =~ '\.vim$' || file_name =~ '\.vimrc$'
Expand Down Expand Up @@ -219,8 +224,8 @@ function! RangeCommentLine()
" for .cpp or .hpp or .java or .C files use //
if file_name =~ '\.cpp$' || file_name =~ '\.hpp$' || file_name =~ '\.java$' || file_name =~ '\.php[2345]\?$' || file_name =~ '\.C$'
execute ":silent! normal :s/\\S/\\/\\/\\0/\<CR>:nohlsearch<CR>=="
" for .c or .h or .pc or .css files use /* */
elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$'
" for .c or .h or .pc or .css or rs files use /* */
elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$'
" if there are previous comments on this line ie /* ... */
if stridx(getline("."), "\/\*") != -1 && stridx(getline("."), "\*\/") != -1
execute ":silent! normal :nohlsearch\<CR>:s/\\([^\\/\\*]*\\)\\(\\/\\*.*\\*\\/\\)/\\1\\*\\/\\2/\<CR>:s/\\([^[:blank:]]\\+\\)/\\/\\*\\1/\<CR>:nohlsearch\<CR>=="
Expand Down Expand Up @@ -284,8 +289,8 @@ function! RangeUnCommentLine()
" for .cpp or .hpp or .java files use //
if file_name =~ '\.cpp$' || file_name =~ '\.hpp$' || file_name =~ '\.java$' || file_name =~ '\.php[2345]\?$' || file_name =~ '\.C$'
execute ":silent! normal :s/\\/\\///\<CR>:nohlsearch\<CR>=="
" for .c or .h or .pc or .css files use /* */
elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$'
" for .c or .h or .pc or .css or rs files use /* */
elseif file_name =~ '\.c$' || file_name =~ '\.h$' || file_name =~ '\.pc$' || file_name =~ '\.css$' || file_name =~ '\.js$' || file_name =~ '\.rs$'
execute ":silent! normal :nohlsearch\<CR>:s/\\/\\*//\<CR>:s/\\*\\///\<CR>:nohlsearch\<CR>=="
" for .vim files use "
elseif file_name =~ '\.vim$' || file_name =~ '\.vimrc$'
Expand Down