When commenting C-style code like C++, JavaScript etc., I use single-line comments to be able to uncomment a previously commented region selectively, i.e
// This
// is
// a single-line style
// comment
If I later want to uncomment lines 2 and 3, for example, I would simply select them and uncomment. With multi-line comments /* */
, however, I would first need to uncomment the whole block, then selectively comment the parts excluding those that I wanted to uncomment in the first place. From this question, I found out that I can change the comment character to //
by putting in my config
(setq-default web-mode-comment-formats (remove '("javascript" . "/*") web-mode-comment-formats))
(add-to-list 'web-mode-comment-formats '("javascript" . "//"))
This, however, does not change the commenting behavior of web-mode. When I select the desired region and run web-mode-comment-or-uncomment-region
, it still exhibits multi-line behavior and uncomments the whole block instead of the region that I select.
How can I uncomment just the selected region instead of the whole block?