I am trying to write a function to replace comments in C using:
// Comment
into
/* COMMENT */
.
This is what I have tried:
function! ANSI()
:%s///(.*)//* 1 *//g
endfunction
This replaces:
7 // Dataset Structure
8 typedef struct {
9 int num_bars; // Number of bars
10 int *data; // Data array
11 int *x_values; // X positions of bars
12 unsigned long color; // Bar color
13 } Dataset;
Into:
7 /* Dataset Structure */
8 typedef struct {
9 int num_bars; /* Number of bars */
10 int *data; /* Data array */
11 int *x_values; /* X positions of bars */
12 unsigned long color; /* Bar color */
13 } Dataset;
But I do not know how to make them uppercase (I am not sure if this can be actually done with regex at all).
3
With the hints and help received:
function! ANSI()
:%s/// *([^ ].*)//* U1 *//g
endfunction
This allows to handle comments where there are more than one space after // characters.