Reputation: 380
I think vim can really do this. I just don't know my way arround search and replace using regex. Can anyone help me around this one.
Update
Thanks to Chris below for helping me around this one. Here is the map.
map <leader>rc :%s@\v/\*([^*]\|[\r\n]\|(\*+([^*/]\|[\r\n])))*\*+/@@g<cr>
Upvotes: 1
Views: 399
Reputation: 90812
:%s@/\*\([^*]\|[\r\n]\|\(\*\+\([^*/]\|[\r\n]\)\)\)*\*\+/@@g
will get rid of all CSS comments (note that's using @
rather than /
as the delimiter to avoid escaping the \
You can also use \v
, the "very magic" flag (read :help \v
), and not need to make the ()|+
characters magic: :%s@\v/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/@@g
.
(This answer is just extending jball's answer by putting in the Vim syntax for it.)
Upvotes: 3
Reputation: 25014
Here's a regex (from Stephen Ostermiller) that should match C style (e.g., /* ... */
and hence CSS) comments:
/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/
Note: this will probably need adaptation to VIM's specific flavor of regex.
Upvotes: 1