In this piece of code, we try to get the extension of the file, and based on that, decide what kind of comment is to be applied. Save the following in a file named vcomments.vim. function! Comment() let ext = tolower(expand('%:e')) if ext == 'php' || ext == 'rb' || ext == 'sh' || ext == 'py' silent s/^/\#/ elseif ext == 'js' silent s:^:\/\/:g elseif ext == 'vim' silent s:^:\":g endif endfunction function! Uncomment() let ext = tolower(expand('%:e')) if ext == 'php' || ext == 'rb' || ext == 'sh' || ext == 'py' silent s/^\#// elseif ext == 'js' silent s:^\/\/::g elseif ext == 'vim' silent s:^\"::g endif endfunction
| Attributes | Values |
|---|---|
| rdfs:label |
|
| rdfs:comment |
|
| Version |
|
| dbkwik:vim/property/wikiPageUsesTemplate | |
| Previous |
|
| Author |
|
| Subpage |
|
| Complexity |
|
| Created |
|
| ID |
|
| NEXT |
|
| abstract |
|