About: Comment & Uncomment multiple lines in Vim   Sponge Permalink

An Entity of Type : owl:Thing, within Data Space : 134.155.108.49:8890 associated with source dataset(s)

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

AttributesValues
rdfs:label
  • Comment & Uncomment multiple lines in Vim
rdfs:comment
  • 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
Version
  • 7(xsd:integer)
dbkwik:vim/property/wikiPageUsesTemplate
Previous
  • 0(xsd:integer)
Author
  • Baliganikhil
Subpage
  • /201205
Complexity
  • basic
Created
  • 2012-05-04(xsd:date)
ID
  • 0(xsd:integer)
NEXT
  • 0(xsd:integer)
abstract
  • 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 Once this is done, put the following in your vimrc: source ~/vcomments.vim map :call Comment() map :call Uncomment() The mappings use Ctrl-A to comment and Ctrl-B to uncomment. Replace these with any convenient keys. To use it, just select the lines to comment by pressing V then moving the cursor up or down to select lines. Then, press Ctrl-A to comment. Similarly, you can uncomment them.
Alternative Linked Data Views: ODE     Raw Data in: CXML | CSV | RDF ( N-Triples N3/Turtle JSON XML ) | OData ( Atom JSON ) | Microdata ( JSON HTML) | JSON-LD    About   
This material is Open Knowledge   W3C Semantic Web Technology [RDF Data] Valid XHTML + RDFa
OpenLink Virtuoso version 07.20.3217, on Linux (x86_64-pc-linux-gnu), Standard Edition
Data on this page belongs to its respective rights holders.
Virtuoso Faceted Browser Copyright © 2009-2012 OpenLink Software