diff --git a/src/getchar.c b/src/getchar.c
index d8d498e..72ddbb9 100644
--- a/src/getchar.c
+++ b/src/getchar.c
@@ -38,13 +38,13 @@
  * Un-escaping is done by vgetc().
  */
 
-#define MINIMAL_SIZE 20			/* minimal size for b_str */
+#define MINIMAL_SIZE 20			// minimal size for b_str
 
 static buffheader_T redobuff = {{NULL, {NUL}}, NULL, 0, 0};
 static buffheader_T old_redobuff = {{NULL, {NUL}}, NULL, 0, 0};
 static buffheader_T recordbuff = {{NULL, {NUL}}, NULL, 0, 0};
 
-static int typeahead_char = 0;		/* typeahead char that's not flushed */
+static int typeahead_char = 0;		// typeahead char that's not flushed
 
 /*
  * when block_redo is TRUE redo buffer will not be changed
@@ -73,20 +73,19 @@
  * typebuf.tb_noremap[typebuf.tb_off] is the first valid flag.
  * (typebuf has been put in globals.h, because check_termcode() needs it).
  */
-#define RM_YES		0	/* tb_noremap: remap */
-#define RM_NONE		1	/* tb_noremap: don't remap */
-#define RM_SCRIPT	2	/* tb_noremap: remap local script mappings */
-#define RM_ABBR		4	/* tb_noremap: don't remap, do abbrev. */
+#define RM_YES		0	// tb_noremap: remap
+#define RM_NONE		1	// tb_noremap: don't remap
+#define RM_SCRIPT	2	// tb_noremap: remap local script mappings
+#define RM_ABBR		4	// tb_noremap: don't remap, do abbrev.
 
-/* typebuf.tb_buf has three parts: room in front (for result of mappings), the
- * middle for typeahead and room for new characters (which needs to be 3 *
- * MAXMAPLEN) for the Amiga).
- */
+// typebuf.tb_buf has three parts: room in front (for result of mappings), the
+// middle for typeahead and room for new characters (which needs to be 3 *
+// MAXMAPLEN) for the Amiga).
 #define TYPELEN_INIT	(5 * (MAXMAPLEN + 3))
-static char_u	typebuf_init[TYPELEN_INIT];	/* initial typebuf.tb_buf */
-static char_u	noremapbuf_init[TYPELEN_INIT];	/* initial typebuf.tb_noremap */
+static char_u	typebuf_init[TYPELEN_INIT];	// initial typebuf.tb_buf
+static char_u	noremapbuf_init[TYPELEN_INIT];	// initial typebuf.tb_noremap
 
-static int	last_recorded_len = 0;	/* number of last recorded chars */
+static int	last_recorded_len = 0;	// number of last recorded chars
 
 static int	read_readbuf(buffheader_T *buf, int advance);
 static void	init_typebuf(void);
@@ -120,7 +119,7 @@
     static char_u *
 get_buffcont(
     buffheader_T	*buffer,
-    int			dozero)	    /* count == zero is not an error */
+    int			dozero)	    // count == zero is not an error
 {
     long_u	    count = 0;
     char_u	    *p = NULL;
@@ -128,7 +127,7 @@
     char_u	    *str;
     buffblock_T *bp;
 
-    /* compute the total length of the string */
+    // compute the total length of the string
     for (bp = buffer->bh_first.b_next; bp != NULL; bp = bp->b_next)
 	count += (long_u)STRLEN(bp->b_str);
 
@@ -196,22 +195,22 @@
 add_buff(
     buffheader_T	*buf,
     char_u		*s,
-    long		slen)	/* length of "s" or -1 */
+    long		slen)	// length of "s" or -1
 {
     buffblock_T *p;
     long_u	    len;
 
     if (slen < 0)
 	slen = (long)STRLEN(s);
-    if (slen == 0)				/* don't add empty strings */
+    if (slen == 0)				// don't add empty strings
 	return;
 
-    if (buf->bh_first.b_next == NULL)	/* first add to list */
+    if (buf->bh_first.b_next == NULL)	// first add to list
     {
 	buf->bh_space = 0;
 	buf->bh_curr = &(buf->bh_first);
     }
-    else if (buf->bh_curr == NULL)	/* buffer has already been read */
+    else if (buf->bh_curr == NULL)	// buffer has already been read
     {
 	iemsg(_("E222: Add to read buffer"));
 	return;
@@ -236,7 +235,7 @@
 	    len = slen;
 	p = alloc(offsetof(buffblock_T, b_str) + len + 1);
 	if (p == NULL)
-	    return; /* no space, just forget it */
+	    return; // no space, just forget it
 	buf->bh_space = (int)(len - slen);
 	vim_strncpy(p->b_str, s, (size_t)slen);
 
@@ -282,7 +281,7 @@
 
 	if (IS_SPECIAL(c) || c == K_SPECIAL || c == NUL)
 	{
-	    /* translate special key code into three byte sequence */
+	    // translate special key code into three byte sequence
 	    temp[0] = K_SPECIAL;
 	    temp[1] = K_SECOND(c);
 	    temp[2] = K_THIRD(c);
@@ -291,7 +290,7 @@
 #ifdef FEAT_GUI
 	else if (c == CSI)
 	{
-	    /* Translate a CSI to a CSI - KS_EXTRA - KE_CSI sequence */
+	    // Translate a CSI to a CSI - KS_EXTRA - KE_CSI sequence
 	    temp[0] = CSI;
 	    temp[1] = KS_EXTRA;
 	    temp[2] = (int)KE_CSI;
@@ -307,10 +306,10 @@
     }
 }
 
-/* First read ahead buffer. Used for translated commands. */
+// First read ahead buffer. Used for translated commands.
 static buffheader_T readbuf1 = {{NULL, {NUL}}, NULL, 0, 0};
 
-/* Second read ahead buffer. Used for redo. */
+// Second read ahead buffer. Used for redo.
 static buffheader_T readbuf2 = {{NULL, {NUL}}, NULL, 0, 0};
 
 /*
@@ -336,7 +335,7 @@
     char_u	c;
     buffblock_T	*curr;
 
-    if (buf->bh_first.b_next == NULL)  /* buffer is empty */
+    if (buf->bh_first.b_next == NULL)  // buffer is empty
 	return NUL;
 
     curr = buf->bh_first.b_next;
@@ -435,8 +434,8 @@
 	typebuf.tb_off = MAXMAPLEN;
 	typebuf.tb_len = 0;
 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL)
-	/* Reset the flag that text received from a client or from feedkeys()
-	 * was inserted in the typeahead buffer. */
+	// Reset the flag that text received from a client or from feedkeys()
+	// was inserted in the typeahead buffer.
 	typebuf_was_filled = FALSE;
 #endif
     }
@@ -493,7 +492,7 @@
     save_redo->sr_old_redobuff = old_redobuff;
     old_redobuff.bh_first.b_next = NULL;
 
-    /* Make a copy, so that ":normal ." in a function works. */
+    // Make a copy, so that ":normal ." in a function works.
     s = get_buffcont(&save_redo->sr_redobuff, FALSE);
     if (s != NULL)
     {
@@ -533,7 +532,7 @@
     void
 AppendToRedobuffLit(
     char_u	*str,
-    int		len)	    /* length of "str" or -1 for up to the NUL */
+    int		len)	    // length of "str" or -1 for up to the NUL
 {
     char_u	*s = str;
     int		c;
@@ -544,18 +543,18 @@
 
     while (len < 0 ? *s != NUL : s - str < len)
     {
-	/* Put a string of normal characters in the redo buffer (that's
-	 * faster). */
+	// Put a string of normal characters in the redo buffer (that's
+	// faster).
 	start = s;
 	while (*s >= ' '
 #ifndef EBCDIC
-		&& *s < DEL	/* EBCDIC: all chars above space are normal */
+		&& *s < DEL	// EBCDIC: all chars above space are normal
 #endif
 		&& (len < 0 || s - str < len))
 	    ++s;
 
-	/* Don't put '0' or '^' as last character, just in case a CTRL-D is
-	 * typed next. */
+	// Don't put '0' or '^' as last character, just in case a CTRL-D is
+	// typed next.
 	if (*s == NUL && (s[-1] == '0' || s[-1] == '^'))
 	    --s;
 	if (s > start)
@@ -564,16 +563,16 @@
 	if (*s == NUL || (len >= 0 && s - str >= len))
 	    break;
 
-	/* Handle a special or multibyte character. */
+	// Handle a special or multibyte character.
 	if (has_mbyte)
-	    /* Handle composing chars separately. */
+	    // Handle composing chars separately.
 	    c = mb_cptr2char_adv(&s);
 	else
 	    c = *s++;
 	if (c < ' ' || c == DEL || (*s == NUL && (c == '0' || c == '^')))
 	    add_char_buff(&redobuff, Ctrl_V);
 
-	/* CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0) */
+	// CTRL-V '0' must be inserted as CTRL-V 048 (EBCDIC: xf0)
 	if (*s == NUL && c == '0')
 #ifdef EBCDIC
 	    add_buff(&redobuff, (char_u *)"xf0", 3L);
@@ -647,7 +646,7 @@
     {
 	if (*s == K_SPECIAL && s[1] != NUL && s[2] != NUL)
 	{
-	    /* Insert special key literally. */
+	    // Insert special key literally.
 	    stuffReadbuffLen(s, 3L);
 	    s += 3;
 	}
@@ -712,22 +711,22 @@
     }
     if ((c = *p) != NUL)
     {
-	/* Reverse the conversion done by add_char_buff() */
-	/* For a multi-byte character get all the bytes and return the
-	 * converted character. */
+	// Reverse the conversion done by add_char_buff()
+	// For a multi-byte character get all the bytes and return the
+	// converted character.
 	if (has_mbyte && (c != K_SPECIAL || p[1] == KS_SPECIAL))
 	    n = MB_BYTE2LEN_CHECK(c);
 	else
 	    n = 1;
 	for (i = 0; ; ++i)
 	{
-	    if (c == K_SPECIAL) /* special key or escaped K_SPECIAL */
+	    if (c == K_SPECIAL) // special key or escaped K_SPECIAL
 	    {
 		c = TO_SPECIAL(p[1], p[2]);
 		p += 2;
 	    }
 #ifdef FEAT_GUI
-	    if (c == CSI)	/* escaped CSI */
+	    if (c == CSI)	// escaped CSI
 		p += 2;
 #endif
 	    if (*++p == NUL && bp->b_next != NULL)
@@ -736,14 +735,14 @@
 		p = bp->b_str;
 	    }
 	    buf[i] = c;
-	    if (i == n - 1)	/* last byte of a character */
+	    if (i == n - 1)	// last byte of a character
 	    {
 		if (n != 1)
 		    c = (*mb_ptr2char)(buf);
 		break;
 	    }
 	    c = *p;
-	    if (c == NUL)	/* cannot happen? */
+	    if (c == NUL)	// cannot happen?
 		break;
 	}
     }
@@ -779,24 +778,24 @@
 {
     int	    c;
 
-    /* init the pointers; return if nothing to redo */
+    // init the pointers; return if nothing to redo
     if (read_redo(TRUE, old_redo) == FAIL)
 	return FAIL;
 
     c = read_redo(FALSE, old_redo);
 
-    /* copy the buffer name, if present */
+    // copy the buffer name, if present
     if (c == '"')
     {
 	add_buff(&readbuf2, (char_u *)"\"", 1L);
 	c = read_redo(FALSE, old_redo);
 
-	/* if a numbered buffer is used, increment the number */
+	// if a numbered buffer is used, increment the number
 	if (c >= '1' && c < '9')
 	    ++c;
 	add_char_buff(&readbuf2, c);
 
-	/* the expression register should be re-evaluated */
+	// the expression register should be re-evaluated
 	if (c == '=')
 	{
 	    add_char_buff(&readbuf2, CAR);
@@ -806,7 +805,7 @@
 	c = read_redo(FALSE, old_redo);
     }
 
-    if (c == 'v')   /* redo Visual */
+    if (c == 'v')   // redo Visual
     {
 	VIsual = curwin->w_cursor;
 	VIsual_active = TRUE;
@@ -816,15 +815,15 @@
 	c = read_redo(FALSE, old_redo);
     }
 
-    /* try to enter the count (in place of a previous count) */
+    // try to enter the count (in place of a previous count)
     if (count)
     {
-	while (VIM_ISDIGIT(c))	/* skip "old" count */
+	while (VIM_ISDIGIT(c))	// skip "old" count
 	    c = read_redo(FALSE, old_redo);
 	add_num_buff(&readbuf2, count);
     }
 
-    /* copy from the redo buffer into the stuff buffer */
+    // copy from the redo buffer into the stuff buffer
     add_char_buff(&readbuf2, c);
     copy_redo(old_redo);
     return OK;
@@ -844,7 +843,7 @@
 	return FAIL;
     start_stuff();
 
-    /* skip the count and the command character */
+    // skip the count and the command character
     while ((c = read_redo(FALSE, FALSE)) != NUL)
     {
 	if (vim_strchr((char_u *)"AaIiRrOo", c) != NULL)
@@ -855,7 +854,7 @@
 	}
     }
 
-    /* copy the typed text from the redo buffer into the stuff buffer */
+    // copy the typed text from the redo buffer into the stuff buffer
     copy_redo(FALSE);
     block_redo = TRUE;
     return OK;
@@ -965,30 +964,30 @@
 	 */
 	newoff = MAXMAPLEN + 4;
 	newlen = typebuf.tb_len + addlen + newoff + 4 * (MAXMAPLEN + 4);
-	if (newlen < 0)		    /* string is getting too long */
+	if (newlen < 0)		    // string is getting too long
 	{
-	    emsg(_(e_toocompl));    /* also calls flush_buffers */
+	    emsg(_(e_toocompl));    // also calls flush_buffers
 	    setcursor();
 	    return FAIL;
 	}
 	s1 = alloc(newlen);
-	if (s1 == NULL)		    /* out of memory */
+	if (s1 == NULL)		    // out of memory
 	    return FAIL;
 	s2 = alloc(newlen);
-	if (s2 == NULL)		    /* out of memory */
+	if (s2 == NULL)		    // out of memory
 	{
 	    vim_free(s1);
 	    return FAIL;
 	}
 	typebuf.tb_buflen = newlen;
 
-	/* copy the old chars, before the insertion point */
+	// copy the old chars, before the insertion point
 	mch_memmove(s1 + newoff, typebuf.tb_buf + typebuf.tb_off,
 							      (size_t)offset);
-	/* copy the new chars */
+	// copy the new chars
 	mch_memmove(s1 + newoff + offset, str, (size_t)addlen);
-	/* copy the old chars, after the insertion point, including the	NUL at
-	 * the end */
+	// copy the old chars, after the insertion point, including the	NUL at
+	// the end
 	mch_memmove(s1 + newoff + offset + addlen,
 				     typebuf.tb_buf + typebuf.tb_off + offset,
 				       (size_t)(typebuf.tb_len - offset + 1));
@@ -1009,7 +1008,7 @@
     }
     typebuf.tb_len += addlen;
 
-    /* If noremap == REMAP_SCRIPT: do remap script-local mappings. */
+    // If noremap == REMAP_SCRIPT: do remap script-local mappings.
     if (noremap == REMAP_SCRIPT)
 	val = RM_SCRIPT;
     else if (noremap == REMAP_SKIP)
@@ -1035,9 +1034,9 @@
 	typebuf.tb_noremap[typebuf.tb_off + i + offset] =
 						  (--nrm >= 0) ? val : RM_YES;
 
-    /* tb_maplen and tb_silent only remember the length of mapped and/or
-     * silent mappings at the start of the buffer, assuming that a mapped
-     * sequence doesn't result in typed characters. */
+    // tb_maplen and tb_silent only remember the length of mapped and/or
+    // silent mappings at the start of the buffer, assuming that a mapped
+    // sequence doesn't result in typed characters.
     if (nottyped || typebuf.tb_maplen > offset)
 	typebuf.tb_maplen += addlen;
     if (silent || typebuf.tb_silent > offset)
@@ -1045,7 +1044,7 @@
 	typebuf.tb_silent += addlen;
 	cmd_silent = TRUE;
     }
-    if (typebuf.tb_no_abbr_cnt && offset == 0)	/* and not used for abbrev.s */
+    if (typebuf.tb_no_abbr_cnt && offset == 0)	// and not used for abbrev.s
 	typebuf.tb_no_abbr_cnt += addlen;
 
     return OK;
@@ -1084,7 +1083,7 @@
  */
     int
 typebuf_changed(
-    int		tb_change_cnt)	/* old value of typebuf.tb_change_cnt */
+    int		tb_change_cnt)	// old value of typebuf.tb_change_cnt
 {
     return (tb_change_cnt != 0 && (typebuf.tb_change_cnt != tb_change_cnt
 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL)
@@ -1121,7 +1120,7 @@
     int	    i;
 
     if (len == 0)
-	return;		/* nothing to do */
+	return;		// nothing to do
 
     typebuf.tb_len -= len;
 
@@ -1148,31 +1147,31 @@
 			 typebuf.tb_noremap + typebuf.tb_off, (size_t)offset);
 	    typebuf.tb_off = MAXMAPLEN;
 	}
-	/* adjust typebuf.tb_buf (include the NUL at the end) */
+	// adjust typebuf.tb_buf (include the NUL at the end)
 	mch_memmove(typebuf.tb_buf + typebuf.tb_off + offset,
 						     typebuf.tb_buf + i + len,
 				       (size_t)(typebuf.tb_len - offset + 1));
-	/* adjust typebuf.tb_noremap[] */
+	// adjust typebuf.tb_noremap[]
 	mch_memmove(typebuf.tb_noremap + typebuf.tb_off + offset,
 						 typebuf.tb_noremap + i + len,
 					   (size_t)(typebuf.tb_len - offset));
     }
 
-    if (typebuf.tb_maplen > offset)		/* adjust tb_maplen */
+    if (typebuf.tb_maplen > offset)		// adjust tb_maplen
     {
 	if (typebuf.tb_maplen < offset + len)
 	    typebuf.tb_maplen = offset;
 	else
 	    typebuf.tb_maplen -= len;
     }
-    if (typebuf.tb_silent > offset)		/* adjust tb_silent */
+    if (typebuf.tb_silent > offset)		// adjust tb_silent
     {
 	if (typebuf.tb_silent < offset + len)
 	    typebuf.tb_silent = offset;
 	else
 	    typebuf.tb_silent -= len;
     }
-    if (typebuf.tb_no_abbr_cnt > offset)	/* adjust tb_no_abbr_cnt */
+    if (typebuf.tb_no_abbr_cnt > offset)	// adjust tb_no_abbr_cnt
     {
 	if (typebuf.tb_no_abbr_cnt < offset + len)
 	    typebuf.tb_no_abbr_cnt = offset;
@@ -1181,8 +1180,8 @@
     }
 
 #if defined(FEAT_CLIENTSERVER) || defined(FEAT_EVAL)
-    /* Reset the flag that text received from a client or from feedkeys()
-     * was inserted in the typeahead buffer. */
+    // Reset the flag that text received from a client or from feedkeys()
+    // was inserted in the typeahead buffer.
     typebuf_was_filled = FALSE;
 #endif
     if (++typebuf.tb_change_cnt == 0)
@@ -1221,7 +1220,7 @@
 	    continue;
 	}
 
-	/* Handle one byte at a time; no translation to be done. */
+	// Handle one byte at a time; no translation to be done.
 	for (i = 0; i < buflen; ++i)
 	    updatescript(buf[i]);
 
@@ -1229,7 +1228,7 @@
 	{
 	    buf[buflen] = NUL;
 	    add_buff(&recordbuff, buf, (long)buflen);
-	    /* remember how many chars were last recorded */
+	    // remember how many chars were last recorded
 	    last_recorded_len += buflen;
 	}
 	buflen = 0;
@@ -1237,12 +1236,12 @@
     may_sync_undo();
 
 #ifdef FEAT_EVAL
-    /* output "debug mode" message next time in debug mode */
+    // output "debug mode" message next time in debug mode
     debug_did_msg = FALSE;
 #endif
 
-    /* Since characters have been typed, consider the following to be in
-     * another mapping.  Search string will be kept in history. */
+    // Since characters have been typed, consider the following to be in
+    // another mapping.  Search string will be kept in history.
     ++maptick;
 }
 
@@ -1277,7 +1276,7 @@
 	return FAIL;
     }
     typebuf.tb_buflen = TYPELEN_INIT;
-    typebuf.tb_off = MAXMAPLEN + 4;  /* can insert without realloc */
+    typebuf.tb_off = MAXMAPLEN + 4;  // can insert without realloc
     typebuf.tb_len = 0;
     typebuf.tb_maplen = 0;
     typebuf.tb_silent = 0;
@@ -1314,7 +1313,7 @@
 {
     init_typebuf();
     saved_typebuf[curscript] = typebuf;
-    /* If out of memory: restore typebuf and close file. */
+    // If out of memory: restore typebuf and close file.
     if (alloc_typebuf() == FAIL)
     {
 	closescript();
@@ -1323,10 +1322,10 @@
     return OK;
 }
 
-static int old_char = -1;	/* character put back by vungetc() */
-static int old_mod_mask;	/* mod_mask for ungotten character */
-static int old_mouse_row;	/* mouse_row related to old_char */
-static int old_mouse_col;	/* mouse_col related to old_char */
+static int old_char = -1;	// character put back by vungetc()
+static int old_mod_mask;	// mod_mask for ungotten character
+static int old_mouse_row;	// mouse_row related to old_char
+static int old_mouse_col;	// mouse_col related to old_char
 
 /*
  * Save all three kinds of typeahead, so that the user must type at a prompt.
@@ -1383,7 +1382,7 @@
     void
 openscript(
     char_u	*name,
-    int		directly)	/* when TRUE execute directly */
+    int		directly)	// when TRUE execute directly
 {
     if (curscript + 1 == NSCRIPT)
     {
@@ -1398,13 +1397,13 @@
 
 #ifdef FEAT_EVAL
     if (ignore_script)
-	/* Not reading from script, also don't open one.  Warning message? */
+	// Not reading from script, also don't open one.  Warning message?
 	return;
 #endif
 
-    if (scriptin[curscript] != NULL)	/* already reading script */
+    if (scriptin[curscript] != NULL)	// already reading script
 	++curscript;
-				/* use NameBuff for expanded name */
+				// use NameBuff for expanded name
     expand_env(name, NameBuff, MAXPATHL);
     if ((scriptin[curscript] = mch_fopen((char *)NameBuff, READBIN)) == NULL)
     {
@@ -1433,9 +1432,9 @@
 	int	save_msg_scroll = msg_scroll;
 
 	State = NORMAL;
-	msg_scroll = FALSE;	/* no msg scrolling in Normal mode */
-	restart_edit = 0;	/* don't go to Insert mode */
-	p_im = FALSE;		/* don't use 'insertmode' */
+	msg_scroll = FALSE;	// no msg scrolling in Normal mode
+	restart_edit = 0;	// don't go to Insert mode
+	p_im = FALSE;		// don't use 'insertmode'
 	clear_oparg(&oa);
 	finish_op = FALSE;
 
@@ -1574,8 +1573,8 @@
     int		i;
 
 #ifdef FEAT_EVAL
-    /* Do garbage collection when garbagecollect() was called previously and
-     * we are now at the toplevel. */
+    // Do garbage collection when garbagecollect() was called previously and
+    // we are now at the toplevel.
     if (may_garbage_collect && want_garbage_collect)
 	garbage_collect(FALSE);
 #endif
@@ -1868,8 +1867,8 @@
     while (c == K_IGNORE || c == K_VER_SCROLLBAR || c == K_HOR_SCROLLBAR);
 
     if (c == K_PS)
-	/* Only handle the first pasted character.  Drop the rest, since we
-	 * don't know what to do with it. */
+	// Only handle the first pasted character.  Drop the rest, since we
+	// don't know what to do with it.
 	c = bracketed_paste(PASTE_ONE_CHAR, FALSE, NULL);
 
     return c;
@@ -1934,8 +1933,8 @@
     int	    retval;
 
 #ifdef FEAT_EVAL
-    /* When test_override("char_avail", 1) was called pretend there is no
-     * typeahead. */
+    // When test_override("char_avail", 1) was called pretend there is no
+    // typeahead.
     if (disable_char_avail_for_testing)
 	return FALSE;
 #endif
@@ -1962,7 +1961,7 @@
     parse_queued_messages();
 #endif
 
-    /* Position the cursor.  Needed after a message that ends in a space. */
+    // Position the cursor.  Needed after a message that ends in a space.
     windgoto(msg_row, msg_col);
 
     ++no_mapping;
@@ -1970,16 +1969,16 @@
     for (;;)
     {
 	if (argvars[0].v_type == VAR_UNKNOWN)
-	    /* getchar(): blocking wait. */
+	    // getchar(): blocking wait.
 	    n = plain_vgetc();
 	else if (tv_get_number_chk(&argvars[0], &error) == 1)
-	    /* getchar(1): only check if char avail */
+	    // getchar(1): only check if char avail
 	    n = vpeekc_any();
 	else if (error || vpeekc_any() == NUL)
-	    /* illegal argument or getchar(0) and no char avail: return zero */
+	    // illegal argument or getchar(0) and no char avail: return zero
 	    n = 0;
 	else
-	    /* getchar(0) and char avail: return char */
+	    // getchar(0) and char avail: return char
 	    n = plain_vgetc();
 
 	if (n == K_IGNORE)
@@ -1997,10 +1996,10 @@
     rettv->vval.v_number = n;
     if (IS_SPECIAL(n) || mod_mask != 0)
     {
-	char_u		temp[10];   /* modifier: 3, mbyte-char: 6, NUL: 1 */
+	char_u		temp[10];   // modifier: 3, mbyte-char: 6, NUL: 1
 	int		i = 0;
 
-	/* Turn a special key into three bytes, plus modifier. */
+	// Turn a special key into three bytes, plus modifier.
 	if (mod_mask != 0)
 	{
 	    temp[i++] = K_SPECIAL;
@@ -2032,8 +2031,8 @@
 
 	    if (row >= 0 && col >= 0)
 	    {
-		/* Find the window at the mouse coordinates and compute the
-		 * text position. */
+		// Find the window at the mouse coordinates and compute the
+		// text position.
 		win = mouse_find_win(&row, &col, FIND_POPUP);
 		if (win == NULL)
 		    return;
@@ -2572,7 +2571,7 @@
 	    else
 		setcursor();
 	    flush_buffers(FLUSH_MINIMAL);
-	    *mapdepth = 0;	/* for next one */
+	    *mapdepth = 0;	// for next one
 	    *keylenp = keylen;
 	    return map_result_fail;
 	}
@@ -2713,15 +2712,15 @@
 vgetorpeek(int advance)
 {
     int		c, c1;
-    int		timedout = FALSE;	    /* waited for more than 1 second
-						for mapping to complete */
-    int		mapdepth = 0;	    /* check for recursive mapping */
-    int		mode_deleted = FALSE;   /* set when mode has been deleted */
+    int		timedout = FALSE;	// waited for more than 1 second
+					// for mapping to complete
+    int		mapdepth = 0;		// check for recursive mapping
+    int		mode_deleted = FALSE;   // set when mode has been deleted
 #ifdef FEAT_CMDL_INFO
     int		new_wcol, new_wrow;
 #endif
 #ifdef FEAT_GUI
-    int		shape_changed = FALSE;  /* adjusted cursor shape */
+    int		shape_changed = FALSE;  // adjusted cursor shape
 #endif
     int		n;
     int		old_wcol, old_wrow;
@@ -2767,13 +2766,13 @@
 	{
 	    if (advance)
 	    {
-		/* KeyTyped = FALSE;  When the command that stuffed something
-		 * was typed, behave like the stuffed command was typed.
-		 * needed for CTRL-W CTRL-] to open a fold, for example. */
+		// KeyTyped = FALSE;  When the command that stuffed something
+		// was typed, behave like the stuffed command was typed.
+		// needed for CTRL-W CTRL-] to open a fold, for example.
 		KeyStuffed = TRUE;
 	    }
 	    if (typebuf.tb_no_abbr_cnt == 0)
-		typebuf.tb_no_abbr_cnt = 1;	/* no abbreviations now */
+		typebuf.tb_no_abbr_cnt = 1;	// no abbreviations now
 	}
 	else
 	{
@@ -2798,10 +2797,10 @@
 		if (typebuf.tb_maplen)
 		    line_breakcheck();
 		else
-		    ui_breakcheck();		/* check for CTRL-C */
+		    ui_breakcheck();		// check for CTRL-C
 		if (got_int)
 		{
-		    /* flush all input */
+		    // flush all input
 		    c = inchar(typebuf.tb_buf, typebuf.tb_buflen - 1, 0L);
 
 		    /*
@@ -2820,8 +2819,8 @@
 
 		    if (advance)
 		    {
-			/* Also record this character, it might be needed to
-			 * get out of Insert mode. */
+			// Also record this character, it might be needed to
+			// get out of Insert mode.
 			*typebuf.tb_buf = c;
 			gotchars(typebuf.tb_buf, 1);
 		    }
@@ -2852,7 +2851,7 @@
  * get a character: 2. from the typeahead buffer
  */
 			c = typebuf.tb_buf[typebuf.tb_off];
-			if (advance)	/* remove chars from tb_buf */
+			if (advance)	// remove chars from tb_buf
 			{
 			    cmd_silent = (typebuf.tb_silent > 0);
 			    if (typebuf.tb_maplen > 0)
@@ -2860,7 +2859,7 @@
 			    else
 			    {
 				KeyTyped = TRUE;
-				/* write char to script file(s) */
+				// write char to script file(s)
 				gotchars(typebuf.tb_buf
 						 + typebuf.tb_off, 1);
 			    }
@@ -2911,7 +2910,7 @@
 			mode_deleted = TRUE;
 		    }
 #ifdef FEAT_GUI
-		    /* may show a different cursor shape */
+		    // may show a different cursor shape
 		    if (gui.in_use && State != NORMAL && !cmd_silent)
 		    {
 			int	    save_State;
@@ -2927,7 +2926,7 @@
 		    old_wcol = curwin->w_wcol;
 		    old_wrow = curwin->w_wrow;
 
-		    /* move cursor left, if possible */
+		    // move cursor left, if possible
 		    if (curwin->w_cursor.col != 0)
 		    {
 			if (curwin->w_wcol > 0)
@@ -2956,7 +2955,7 @@
 					   + curwin->w_wcol / curwin->w_width;
 				curwin->w_wcol %= curwin->w_width;
 				curwin->w_wcol += curwin_col_off();
-				col = 0;	/* no correction needed */
+				col = 0;	// no correction needed
 			    }
 			    else
 			    {
@@ -2972,8 +2971,8 @@
 			}
 			if (has_mbyte && col > 0 && curwin->w_wcol > 0)
 			{
-			    /* Correct when the cursor is on the right halve
-			     * of a double-wide character. */
+			    // Correct when the cursor is on the right halve
+			    // of a double-wide character.
 			    ptr = ml_get_curline();
 			    col -= (*mb_head_off)(ptr, ptr + col);
 			    if ((*mb_ptr2cells)(ptr + col) > 1)
@@ -2990,15 +2989,15 @@
 		    curwin->w_wrow = old_wrow;
 		}
 		if (c < 0)
-		    continue;	/* end of input script reached */
+		    continue;	// end of input script reached
 
-		/* Allow mapping for just typed characters. When we get here c
-		 * is the number of extra bytes and typebuf.tb_len is 1. */
+		// Allow mapping for just typed characters. When we get here c
+		// is the number of extra bytes and typebuf.tb_len is 1.
 		for (n = 1; n <= c; ++n)
 		    typebuf.tb_noremap[typebuf.tb_off + n] = RM_YES;
 		typebuf.tb_len += c;
 
-		/* buffer full, don't map */
+		// buffer full, don't map
 		if (typebuf.tb_len >= typebuf.tb_maplen + MAXMAPLEN)
 		{
 		    timedout = TRUE;
@@ -3011,20 +3010,20 @@
 		    static int tc = 0;
 #endif
 
-		    /* No typeahead left and inside ":normal".  Must return
-		     * something to avoid getting stuck.  When an incomplete
-		     * mapping is present, behave like it timed out. */
+		    // No typeahead left and inside ":normal".  Must return
+		    // something to avoid getting stuck.  When an incomplete
+		    // mapping is present, behave like it timed out.
 		    if (typebuf.tb_len > 0)
 		    {
 			timedout = TRUE;
 			continue;
 		    }
-		    /* When 'insertmode' is set, ESC just beeps in Insert
-		     * mode.  Use CTRL-L to make edit() return.
-		     * For the command line only CTRL-C always breaks it.
-		     * For the cmdline window: Alternate between ESC and
-		     * CTRL-C: ESC for most situations and CTRL-C to close the
-		     * cmdline window. */
+		    // When 'insertmode' is set, ESC just beeps in Insert
+		    // mode.  Use CTRL-L to make edit() return.
+		    // For the command line only CTRL-C always breaks it.
+		    // For the cmdline window: Alternate between ESC and
+		    // CTRL-C: ESC for most situations and CTRL-C to close the
+		    // cmdline window.
 		    if (p_im && (State & INSERT))
 			c = Ctrl_L;
 #ifdef FEAT_TERMINAL
@@ -3048,18 +3047,18 @@
 /*
  * get a character: 3. from the user - update display
  */
-		/* In insert mode a screen update is skipped when characters
-		 * are still available.  But when those available characters
-		 * are part of a mapping, and we are going to do a blocking
-		 * wait here.  Need to update the screen to display the
-		 * changed text so far. Also for when 'lazyredraw' is set and
-		 * redrawing was postponed because there was something in the
-		 * input buffer (e.g., termresponse). */
+		// In insert mode a screen update is skipped when characters
+		// are still available.  But when those available characters
+		// are part of a mapping, and we are going to do a blocking
+		// wait here.  Need to update the screen to display the
+		// changed text so far. Also for when 'lazyredraw' is set and
+		// redrawing was postponed because there was something in the
+		// input buffer (e.g., termresponse).
 		if (((State & INSERT) != 0 || p_lz) && (State & CMDLINE) == 0
 			  && advance && must_redraw != 0 && !need_wait_return)
 		{
 		    update_screen(0);
-		    setcursor(); /* put cursor back where it belongs */
+		    setcursor(); // put cursor back where it belongs
 		}
 
 		/*
@@ -3076,18 +3075,18 @@
 		    if (((State & (NORMAL | INSERT)) || State == LANGMAP)
 			    && State != HITRETURN)
 		    {
-			/* this looks nice when typing a dead character map */
+			// this looks nice when typing a dead character map
 			if (State & INSERT
 			    && ptr2cells(typebuf.tb_buf + typebuf.tb_off
 						   + typebuf.tb_len - 1) == 1)
 			{
 			    edit_putchar(typebuf.tb_buf[typebuf.tb_off
 						+ typebuf.tb_len - 1], FALSE);
-			    setcursor(); /* put cursor back where it belongs */
+			    setcursor(); // put cursor back where it belongs
 			    c1 = 1;
 			}
 #ifdef FEAT_CMDL_INFO
-			/* need to use the col and row from above here */
+			// need to use the col and row from above here
 			old_wcol = curwin->w_wcol;
 			old_wrow = curwin->w_wrow;
 			curwin->w_wcol = new_wcol;
@@ -3103,7 +3102,7 @@
 #endif
 		    }
 
-		    /* this looks nice when typing a dead character map */
+		    // this looks nice when typing a dead character map
 		    if ((State & CMDLINE)
 #if defined(FEAT_CRYPT) || defined(FEAT_EVAL)
 			    && cmdline_star == 0
@@ -3156,37 +3155,37 @@
 		    if (State & CMDLINE)
 			unputcmdline();
 		    else
-			setcursor();	/* put cursor back where it belongs */
+			setcursor();	// put cursor back where it belongs
 		}
 
 		if (c < 0)
-		    continue;		/* end of input script reached */
-		if (c == NUL)		/* no character available */
+		    continue;		// end of input script reached
+		if (c == NUL)		// no character available
 		{
 		    if (!advance)
 			break;
-		    if (wait_tb_len > 0)	/* timed out */
+		    if (wait_tb_len > 0)	// timed out
 		    {
 			timedout = TRUE;
 			continue;
 		    }
 		}
 		else
-		{	    /* allow mapping for just typed characters */
+		{	    // allow mapping for just typed characters
 		    while (typebuf.tb_buf[typebuf.tb_off
 						     + typebuf.tb_len] != NUL)
 			typebuf.tb_noremap[typebuf.tb_off
 						 + typebuf.tb_len++] = RM_YES;
 #ifdef HAVE_INPUT_METHOD
-		    /* Get IM status right after getting keys, not after the
-		     * timeout for a mapping (focus may be lost by then). */
+		    // Get IM status right after getting keys, not after the
+		    // timeout for a mapping (focus may be lost by then).
 		    vgetc_im_active = im_get_status();
 #endif
 		}
-	    }	    /* for (;;) */
-	}	/* if (!character from stuffbuf) */
+	    }	    // for (;;)
+	}	// if (!character from stuffbuf)
 
-	/* if advance is FALSE don't loop on NULs */
+	// if advance is FALSE don't loop on NULs
     } while ((c < 0 && c != K_CANCEL) || (advance && c == NUL));
 
     /*
@@ -3199,20 +3198,20 @@
 	if (c == ESC && !mode_deleted && !no_mapping && mode_displayed)
 	{
 	    if (typebuf.tb_len && !KeyTyped)
-		redraw_cmdline = TRUE;	    /* delete mode later */
+		redraw_cmdline = TRUE;	    // delete mode later
 	    else
 		unshowmode(FALSE);
 	}
 	else if (c != ESC && mode_deleted)
 	{
 	    if (typebuf.tb_len && !KeyTyped)
-		redraw_cmdline = TRUE;	    /* show mode later */
+		redraw_cmdline = TRUE;	    // show mode later
 	    else
 		showmode();
 	}
     }
 #ifdef FEAT_GUI
-    /* may unshow different cursor shape */
+    // may unshow different cursor shape
     if (gui.in_use && shape_changed)
 	gui_update_cursor(TRUE, FALSE);
 #endif
@@ -3260,14 +3259,14 @@
 inchar(
     char_u	*buf,
     int		maxlen,
-    long	wait_time)	    /* milli seconds */
+    long	wait_time)	    // milli seconds
 {
-    int		len = 0;	    /* init for GCC */
-    int		retesc = FALSE;	    /* return ESC with gotint */
+    int		len = 0;	    // init for GCC
+    int		retesc = FALSE;	    // return ESC with gotint
     int		script_char;
     int		tb_change_cnt = typebuf.tb_change_cnt;
 
-    if (wait_time == -1L || wait_time > 100L)  /* flush output before waiting */
+    if (wait_time == -1L || wait_time > 100L)  // flush output before waiting
     {
 	cursor_on();
 	out_flush_cursor(FALSE, FALSE);
@@ -3284,10 +3283,10 @@
      */
     if (State != HITRETURN)
     {
-	did_outofmem_msg = FALSE;   /* display out of memory message (again) */
-	did_swapwrite_msg = FALSE;  /* display swap file write error again */
+	did_outofmem_msg = FALSE;   // display out of memory message (again)
+	did_swapwrite_msg = FALSE;  // display swap file write error again
     }
-    undo_off = FALSE;		    /* restart undo now */
+    undo_off = FALSE;		    // restart undo now
 
     /*
      * Get a character from a script file if there is one.
@@ -3306,9 +3305,9 @@
 
 	if (got_int || (script_char = getc(scriptin[curscript])) < 0)
 	{
-	    /* Reached EOF.
-	     * Careful: closescript() frees typebuf.tb_buf[] and buf[] may
-	     * point inside typebuf.tb_buf[].  Don't use buf[] after this! */
+	    // Reached EOF.
+	    // Careful: closescript() frees typebuf.tb_buf[] and buf[] may
+	    // point inside typebuf.tb_buf[].  Don't use buf[] after this!
 	    closescript();
 	    /*
 	     * When reading script file is interrupted, return an ESC to get
@@ -3327,7 +3326,7 @@
 	}
     }
 
-    if (script_char < 0)	/* did not get a character from script */
+    if (script_char < 0)	// did not get a character from script
     {
 	/*
 	 * If we got an interrupt, skip all previously typed characters and
@@ -3365,14 +3364,14 @@
 	len = ui_inchar(buf, maxlen / 3, wait_time, tb_change_cnt);
     }
 
-    /* If the typebuf was changed further down, it is like nothing was added by
-     * this call. */
+    // If the typebuf was changed further down, it is like nothing was added by
+    // this call.
     if (typebuf_changed(tb_change_cnt))
 	return 0;
 
-    /* Note the change in the typeahead buffer, this matters for when
-     * vgetorpeek() is called recursively, e.g. using getchar(1) in a timer
-     * function. */
+    // Note the change in the typeahead buffer, this matters for when
+    // vgetorpeek() is called recursively, e.g. using getchar(1) in a timer
+    // function.
     if (len > 0 && ++typebuf.tb_change_cnt == 0)
 	typebuf.tb_change_cnt = 1;
 
@@ -3400,15 +3399,15 @@
     for (i = len; --i >= 0; ++p)
     {
 #ifdef FEAT_GUI
-	/* When the GUI is used any character can come after a CSI, don't
-	 * escape it. */
+	// When the GUI is used any character can come after a CSI, don't
+	// escape it.
 	if (gui.in_use && p[0] == CSI && i >= 2)
 	{
 	    p += 2;
 	    i -= 2;
 	}
 # ifndef MSWIN
-	/* When the GUI is not used CSI needs to be escaped. */
+	// When the GUI is not used CSI needs to be escaped.
 	else if (!gui.in_use && p[0] == CSI)
 	{
 	    mch_memmove(p + 3, p + 1, (size_t)i);
diff --git a/src/gui.c b/src/gui.c
index 3e5eff5..0a7f346 100644
--- a/src/gui.c
+++ b/src/gui.c
@@ -10,7 +10,7 @@
 
 #include "vim.h"
 
-/* Structure containing all the GUI information */
+// Structure containing all the GUI information
 gui_T gui;
 
 #if !defined(FEAT_GUI_GTK)
@@ -38,7 +38,7 @@
 
 static int gui_read_child_pipe(int fd);
 
-/* Return values for gui_read_child_pipe */
+// Return values for gui_read_child_pipe
 enum {
     GUI_CHILD_IO_ERROR,
     GUI_CHILD_OK,
@@ -48,8 +48,8 @@
 
 static void gui_attempt_start(void);
 
-static int can_update_cursor = TRUE; /* can display the cursor */
-static int disable_flush = 0;	/* If > 0, gui_mch_flush() is disabled. */
+static int can_update_cursor = TRUE; // can display the cursor
+static int disable_flush = 0;	// If > 0, gui_mch_flush() is disabled.
 
 /*
  * The Athena scrollbars can move the thumb to after the end of the scrollbar,
@@ -78,9 +78,9 @@
 
     old_term = vim_strsave(T_NAME);
 
-    settmode(TMODE_COOK);		/* stop RAW mode */
+    settmode(TMODE_COOK);		// stop RAW mode
     if (full_screen)
-	cursor_on();			/* needed for ":gui" in .vimrc */
+	cursor_on();			// needed for ":gui" in .vimrc
     full_screen = FALSE;
 
     ++recursive;
@@ -125,30 +125,29 @@
 #endif
     {
 #ifdef FEAT_GUI_GTK
-	/* If there is 'f' in 'guioptions' and specify -g argument,
-	 * gui_mch_init_check() was not called yet.  */
+	// If there is 'f' in 'guioptions' and specify -g argument,
+	// gui_mch_init_check() was not called yet.
 	if (gui_mch_init_check() != OK)
 	    getout_preserve_modified(1);
 #endif
 	gui_attempt_start();
     }
 
-    if (!gui.in_use)			/* failed to start GUI */
+    if (!gui.in_use)			// failed to start GUI
     {
-	/* Back to old term settings
-	 *
-	 * FIXME: If we got here because a child process failed and flagged to
-	 * the parent to resume, and X11 is enabled with FEAT_TITLE, this will
-	 * hit an X11 I/O error and do a longjmp(), leaving recursive
-	 * permanently set to 1. This is probably not as big a problem as it
-	 * sounds, because gui_mch_init() in both gui_x11.c and gui_gtk_x11.c
-	 * return "OK" unconditionally, so it would be very difficult to
-	 * actually hit this case.
-	 */
+	// Back to old term settings
+	//
+	// FIXME: If we got here because a child process failed and flagged to
+	// the parent to resume, and X11 is enabled with FEAT_TITLE, this will
+	// hit an X11 I/O error and do a longjmp(), leaving recursive
+	// permanently set to 1. This is probably not as big a problem as it
+	// sounds, because gui_mch_init() in both gui_x11.c and gui_gtk_x11.c
+	// return "OK" unconditionally, so it would be very difficult to
+	// actually hit this case.
 	termcapinit(old_term);
-	settmode(TMODE_RAW);		/* restart RAW mode */
+	settmode(TMODE_RAW);		// restart RAW mode
 #ifdef FEAT_TITLE
-	set_title_defaults();		/* set 'title' and 'icon' again */
+	set_title_defaults();		// set 'title' and 'icon' again
 #endif
 #if defined(GUI_MAY_SPAWN) && defined(EXPERIMENTAL_GUI_CMD)
 	if (msg)
@@ -158,8 +157,8 @@
 
     vim_free(old_term);
 
-    /* If the GUI started successfully, trigger the GUIEnter event, otherwise
-     * the GUIFailed event. */
+    // If the GUI started successfully, trigger the GUIEnter event, otherwise
+    // the GUIFailed event.
     gui_mch_update();
     apply_autocmds(gui.in_use ? EVENT_GUIENTER : EVENT_GUIFAILED,
 						   NULL, NULL, FALSE, curbuf);
@@ -202,7 +201,7 @@
 	    set_vim_var_nr(VV_WINDOWID, (long)x11_window);
 # endif
 
-	/* Display error messages in a dialog now. */
+	// Display error messages in a dialog now.
 	display_errors();
     }
 #endif
@@ -211,7 +210,7 @@
 
 #ifdef GUI_MAY_FORK
 
-/* for waitpid() */
+// for waitpid()
 # if defined(HAVE_SYS_WAIT_H) || defined(HAVE_UNION_WAIT)
 #  include <sys/wait.h>
 # endif
@@ -231,38 +230,38 @@
     static void
 gui_do_fork(void)
 {
-    int		pipefd[2];	/* pipe between parent and child */
+    int		pipefd[2];	// pipe between parent and child
     int		pipe_error;
     int		status;
     int		exit_status;
     pid_t	pid = -1;
 
-    /* Setup a pipe between the child and the parent, so that the parent
-     * knows when the child has done the setsid() call and is allowed to
-     * exit. */
+    // Setup a pipe between the child and the parent, so that the parent
+    // knows when the child has done the setsid() call and is allowed to
+    // exit.
     pipe_error = (pipe(pipefd) < 0);
     pid = fork();
-    if (pid < 0)	    /* Fork error */
+    if (pid < 0)	    // Fork error
     {
 	emsg(_("E851: Failed to create a new process for the GUI"));
 	return;
     }
-    else if (pid > 0)	    /* Parent */
+    else if (pid > 0)	    // Parent
     {
-	/* Give the child some time to do the setsid(), otherwise the
-	 * exit() may kill the child too (when starting gvim from inside a
-	 * gvim). */
+	// Give the child some time to do the setsid(), otherwise the
+	// exit() may kill the child too (when starting gvim from inside a
+	// gvim).
 	if (!pipe_error)
 	{
-	    /* The read returns when the child closes the pipe (or when
-	     * the child dies for some reason). */
+	    // The read returns when the child closes the pipe (or when
+	    // the child dies for some reason).
 	    close(pipefd[1]);
 	    status = gui_read_child_pipe(pipefd[0]);
 	    if (status == GUI_CHILD_FAILED)
 	    {
-		/* The child failed to start the GUI, so the caller must
-		 * continue. There may be more error information written
-		 * to stderr by the child. */
+		// The child failed to start the GUI, so the caller must
+		// continue. There may be more error information written
+		// to stderr by the child.
 # ifdef __NeXT__
 		wait4(pid, &exit_status, 0, (struct rusage *)0);
 # else
@@ -275,14 +274,14 @@
 	    {
 		pipe_error = TRUE;
 	    }
-	    /* else GUI_CHILD_OK: parent exit */
+	    // else GUI_CHILD_OK: parent exit
 	}
 
 	if (pipe_error)
 	    ui_delay(301L, TRUE);
 
-	/* When swapping screens we may need to go to the next line, e.g.,
-	 * after a hit-enter prompt and using ":gui". */
+	// When swapping screens we may need to go to the next line, e.g.,
+	// after a hit-enter prompt and using ":gui".
 	if (newline_on_exit)
 	    mch_errmsg("\r\n");
 
@@ -292,10 +291,10 @@
 	 */
 	_exit(0);
     }
-    /* Child */
+    // Child
 
 #ifdef FEAT_GUI_GTK
-    /* Call gtk_init_check() here after fork(). See gui_init_check(). */
+    // Call gtk_init_check() here after fork(). See gui_init_check().
     if (gui_mch_init_check() != OK)
 	getout_preserve_modified(1);
 #endif
@@ -315,14 +314,14 @@
 	close(pipefd[0]);
 
 # if defined(FEAT_GUI_GNOME) && defined(FEAT_SESSION)
-    /* Tell the session manager our new PID */
+    // Tell the session manager our new PID
     gui_mch_forked();
 # endif
 
-    /* Try to start the GUI */
+    // Try to start the GUI
     gui_attempt_start();
 
-    /* Notify the parent */
+    // Notify the parent
     if (!pipe_error)
     {
 	if (gui.in_use)
@@ -332,7 +331,7 @@
 	close(pipefd[1]);
     }
 
-    /* If we failed to start the GUI, exit now. */
+    // If we failed to start the GUI, exit now.
     if (!gui.in_use)
 	getout_preserve_modified(1);
 }
@@ -364,7 +363,7 @@
     return GUI_CHILD_FAILED;
 }
 
-#endif /* GUI_MAY_FORK */
+#endif // GUI_MAY_FORK
 
 /*
  * Call this when vim starts up, whether or not the GUI is started
@@ -372,8 +371,8 @@
     void
 gui_prepare(int *argc, char **argv)
 {
-    gui.in_use = FALSE;		    /* No GUI yet (maybe later) */
-    gui.starting = FALSE;	    /* No GUI yet (maybe later) */
+    gui.in_use = FALSE;		    // No GUI yet (maybe later)
+    gui.starting = FALSE;	    // No GUI yet (maybe later)
     gui_mch_prepare(argc, argv);
 }
 
@@ -397,7 +396,7 @@
 
     gui.shell_created = FALSE;
     gui.dying = FALSE;
-    gui.in_focus = TRUE;		/* so the guicursor setting works */
+    gui.in_focus = TRUE;		// so the guicursor setting works
     gui.dragged_sb = SBAR_NONE;
     gui.dragged_wp = NULL;
     gui.pointer_hidden = FALSE;
@@ -441,7 +440,7 @@
     gui.menu_font = NOFONT;
 #  endif
 # endif
-    gui.menu_is_active = TRUE;	    /* default: include menu */
+    gui.menu_is_active = TRUE;	    // default: include menu
 # ifndef FEAT_GUI_GTK
     gui.menu_height = MENU_DEFAULT_HEIGHT;
     gui.menu_width = 0;
@@ -499,7 +498,7 @@
 
 	clip_init(TRUE);
 
-	/* If can't initialize, don't try doing the rest */
+	// If can't initialize, don't try doing the rest
 	if (gui_init_check() == FAIL)
 	{
 	    --recursive;
@@ -596,8 +595,8 @@
 		{
 		    stat_T s;
 
-		    /* if ".gvimrc" file is not owned by user, set 'secure'
-		     * mode */
+		    // if ".gvimrc" file is not owned by user, set 'secure'
+		    // mode
 		    if (mch_stat(GVIMRC_FILE, &s) || s.st_uid != getuid())
 			secure = p_secure;
 		}
@@ -638,19 +637,19 @@
 	--recursive;
     }
 
-    /* If recursive call opened the shell, return here from the first call */
+    // If recursive call opened the shell, return here from the first call
     if (gui.in_use)
 	return;
 
     /*
      * Create the GUI shell.
      */
-    gui.in_use = TRUE;		/* Must be set after menus have been set up */
+    gui.in_use = TRUE;		// Must be set after menus have been set up
     if (gui_mch_init() == FAIL)
 	goto error;
 
-    /* Avoid a delay for an error message that was printed in the terminal
-     * where Vim was started. */
+    // Avoid a delay for an error message that was printed in the terminal
+    // where Vim was started.
     emsg_on_display = FALSE;
     msg_scrolled = 0;
     clear_sb_text(TRUE);
@@ -686,7 +685,7 @@
     gui.num_rows = Rows;
     gui_reset_scroll_region();
 
-    /* Create initial scrollbars */
+    // Create initial scrollbars
     FOR_ALL_WINDOWS(wp)
     {
 	gui_create_scrollbar(&wp->w_scrollbars[SBAR_LEFT], SBAR_LEFT, wp);
@@ -701,10 +700,10 @@
     sign_gui_started();
 #endif
 
-    /* Configure the desired menu and scrollbars */
+    // Configure the desired menu and scrollbars
     gui_init_which_components(NULL);
 
-    /* All components of the GUI have been created now */
+    // All components of the GUI have been created now
     gui.shell_created = TRUE;
 
 #ifdef FEAT_GUI_MSWIN
@@ -723,8 +722,8 @@
 # endif
 #endif
 #if defined(FEAT_GUI_MOTIF) && defined(FEAT_MENU)
-    /* Need to set the size of the menubar after all the menus have been
-     * created. */
+    // Need to set the size of the menubar after all the menus have been
+    // created.
     gui_mch_compute_menu_height((Widget)0);
 #endif
 
@@ -739,16 +738,16 @@
 #endif
 	init_gui_options();
 #ifdef FEAT_ARABIC
-	/* Our GUI can't do bidi. */
+	// Our GUI can't do bidi.
 	p_tbidi = FALSE;
 #endif
 #if defined(FEAT_GUI_GTK)
-	/* Give GTK+ a chance to put all widget's into place. */
+	// Give GTK+ a chance to put all widget's into place.
 	gui_mch_update();
 
 # ifdef FEAT_MENU
-	/* If there is no 'm' in 'guioptions' we need to remove the menu now.
-	 * It was still there to make F10 work. */
+	// If there is no 'm' in 'guioptions' we need to remove the menu now.
+	// It was still there to make F10 work.
 	if (vim_strchr(p_go, GO_MENUS) == NULL)
 	{
 	    --gui.starting;
@@ -758,19 +757,19 @@
 	}
 # endif
 
-	/* Now make sure the shell fits on the screen. */
+	// Now make sure the shell fits on the screen.
 	if (gui_mch_maximized())
 	    gui_set_shellsize(FALSE, TRUE, RESIZE_BOTH);
 	else
 	    gui_set_shellsize(TRUE, TRUE, RESIZE_BOTH);
 #endif
-	/* When 'lines' was set while starting up the topframe may have to be
-	 * resized. */
+	// When 'lines' was set while starting up the topframe may have to be
+	// resized.
 	win_new_shellsize();
 
 #ifdef FEAT_BEVAL_GUI
-	/* Always create the Balloon Evaluation area, but disable it when
-	 * 'ballooneval' is off. */
+	// Always create the Balloon Evaluation area, but disable it when
+	// 'ballooneval' is off.
 	if (balloonEval != NULL)
 	{
 # ifdef FEAT_VARTABS
@@ -804,8 +803,8 @@
 	if (!im_xim_isvalid_imactivate())
 	    emsg(_("E599: Value of 'imactivatekey' is invalid"));
 #endif
-	/* When 'cmdheight' was set during startup it may not have taken
-	 * effect yet. */
+	// When 'cmdheight' was set during startup it may not have taken
+	// effect yet.
 	if (p_ch != 1L)
 	    command_height();
 
@@ -814,7 +813,7 @@
 
 error2:
 #ifdef FEAT_GUI_X11
-    /* undo gui_mch_init() */
+    // undo gui_mch_init()
     gui_mch_uninit();
 #endif
 
@@ -827,8 +826,8 @@
     void
 gui_exit(int rc)
 {
-    /* don't free the fonts, it leads to a BUS error
-     * richard@whitequeen.com Jul 99 */
+    // don't free the fonts, it leads to a BUS error
+    // richard@whitequeen.com Jul 99
     free_highlight_fonts();
     gui.in_use = FALSE;
     gui_mch_exit(rc);
@@ -850,7 +849,7 @@
 
     save_cmdmod = cmdmod;
 
-    /* Only exit when there are no changed files */
+    // Only exit when there are no changed files
     exiting = TRUE;
 # ifdef FEAT_BROWSE
     cmdmod.browse = TRUE;
@@ -858,14 +857,14 @@
 # if defined(FEAT_GUI_DIALOG) || defined(FEAT_CON_DIALOG)
     cmdmod.confirm = TRUE;
 # endif
-    /* If there are changed buffers, present the user with a dialog if
-     * possible, otherwise give an error message. */
+    // If there are changed buffers, present the user with a dialog if
+    // possible, otherwise give an error message.
     if (!check_changed_any(FALSE, FALSE))
 	getout(0);
 
     exiting = FALSE;
     cmdmod = save_cmdmod;
-    gui_update_screen();	/* redraw, window may show changed buffer */
+    gui_update_screen();	// redraw, window may show changed buffer
 }
 #endif
 
@@ -894,26 +893,26 @@
     else
     {
 #ifdef FEAT_XFONTSET
-	/* When using a fontset, the whole list of fonts is one name. */
+	// When using a fontset, the whole list of fonts is one name.
 	if (fontset)
 	    ret = gui_mch_init_font(font_list, TRUE);
 	else
 #endif
 	    while (*font_list != NUL)
 	    {
-		/* Isolate one comma separated font name. */
+		// Isolate one comma separated font name.
 		(void)copy_option_part(&font_list, font_name, FONTLEN, ",");
 
-		/* Careful!!!  The Win32 version of gui_mch_init_font(), when
-		 * called with "*" will change p_guifont to the selected font
-		 * name, which frees the old value.  This makes font_list
-		 * invalid.  Thus when OK is returned here, font_list must no
-		 * longer be used! */
+		// Careful!!!  The Win32 version of gui_mch_init_font(), when
+		// called with "*" will change p_guifont to the selected font
+		// name, which frees the old value.  This makes font_list
+		// invalid.  Thus when OK is returned here, font_list must no
+		// longer be used!
 		if (gui_mch_init_font(font_name, FALSE) == OK)
 		{
 #if !defined(FEAT_GUI_GTK)
-		    /* If it's a Unicode font, try setting 'guifontwide' to a
-		     * similar double-width font. */
+		    // If it's a Unicode font, try setting 'guifontwide' to a
+		    // similar double-width font.
 		    if ((p_guifontwide == NULL || *p_guifontwide == NUL)
 				&& strstr((char *)font_name, "10646") != NULL)
 			set_guifontwide(font_name);
@@ -939,7 +938,7 @@
     if (ret == OK)
     {
 #ifndef FEAT_GUI_GTK
-	/* Set normal font as current font */
+	// Set normal font as current font
 # ifdef FEAT_XFONTSET
 	if (gui.fontset != NOFONTSET)
 	    gui_mch_set_fontset(gui.fontset);
@@ -961,7 +960,7 @@
 set_guifontwide(char_u *name)
 {
     int		i = 0;
-    char_u	wide_name[FONTLEN + 10]; /* room for 2 * width and '*' */
+    char_u	wide_name[FONTLEN + 10]; // room for 2 * width and '*'
     char_u	*wp = NULL;
     char_u	*p;
     GuiFont	font;
@@ -973,18 +972,18 @@
 	if (*p == '-')
 	{
 	    ++i;
-	    if (i == 6)		/* font type: change "--" to "-*-" */
+	    if (i == 6)		// font type: change "--" to "-*-"
 	    {
 		if (p[1] == '-')
 		    *wp++ = '*';
 	    }
-	    else if (i == 12)	/* found the width */
+	    else if (i == 12)	// found the width
 	    {
 		++p;
 		i = getdigits(&p);
 		if (i != 0)
 		{
-		    /* Double the width specification. */
+		    // Double the width specification.
 		    sprintf((char *)wp, "%d%s", i * 2, p);
 		    font = gui_mch_get_font(wide_name, FALSE);
 		    if (font != NOFONT)
@@ -1000,7 +999,7 @@
 	}
     }
 }
-#endif /* !FEAT_GUI_GTK */
+#endif // !FEAT_GUI_GTK
 
 /*
  * Get the font for 'guifontwide'.
@@ -1013,14 +1012,14 @@
     char_u	font_name[FONTLEN];
     char_u	*p;
 
-    if (!gui.in_use)	    /* Can't allocate font yet, assume it's OK. */
-	return OK;	    /* Will give an error message later. */
+    if (!gui.in_use)	    // Can't allocate font yet, assume it's OK.
+	return OK;	    // Will give an error message later.
 
     if (p_guifontwide != NULL && *p_guifontwide != NUL)
     {
 	for (p = p_guifontwide; *p != NUL; )
 	{
-	    /* Isolate one comma separated font name. */
+	    // Isolate one comma separated font name.
 	    (void)copy_option_part(&p, font_name, FONTLEN, ",");
 	    font = gui_mch_get_font(font_name, FALSE);
 	    if (font != NOFONT)
@@ -1032,7 +1031,7 @@
 
     gui_mch_free_font(gui.wide_font);
 #ifdef FEAT_GUI_GTK
-    /* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */
+    // Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'.
     if (font != NOFONT && gui.norm_font != NOFONT
 			 && pango_font_description_equal(font, gui.norm_font))
     {
@@ -1081,8 +1080,8 @@
  */
     void
 gui_update_cursor(
-    int		force,		/* when TRUE, update even when not moved */
-    int		clear_selection)/* clear selection under cursor */
+    int		force,		 // when TRUE, update even when not moved
+    int		clear_selection) // clear selection under cursor
 {
     int		cur_width = 0;
     int		cur_height = 0;
@@ -1093,13 +1092,13 @@
     guicolor_T	shape_fg = INVALCOLOR;
     guicolor_T	shape_bg = INVALCOLOR;
 #endif
-    guicolor_T	cfg, cbg, cc;	/* cursor fore-/background color */
-    int		cattr;		/* cursor attributes */
+    guicolor_T	cfg, cbg, cc;	// cursor fore-/background color
+    int		cattr;		// cursor attributes
     int		attr;
     attrentry_T *aep = NULL;
 
-    /* Don't update the cursor when halfway busy scrolling or the screen size
-     * doesn't match 'columns' and 'lines.  ScreenLines[] isn't valid then. */
+    // Don't update the cursor when halfway busy scrolling or the screen size
+    // doesn't match 'columns' and 'lines.  ScreenLines[] isn't valid then.
     if (!can_update_cursor || screen_Columns != gui.num_cols
 					       || screen_Rows != gui.num_rows)
 	return;
@@ -1118,15 +1117,15 @@
 	gui.cursor_row = gui.row;
 	gui.cursor_col = gui.col;
 
-	/* Only write to the screen after ScreenLines[] has been initialized */
+	// Only write to the screen after ScreenLines[] has been initialized
 	if (!screen_cleared || ScreenLines == NULL)
 	    return;
 
-	/* Clear the selection if we are about to write over it */
+	// Clear the selection if we are about to write over it
 	if (clear_selection)
 	    clip_may_clear_selection(gui.row, gui.row);
-	/* Check that the cursor is inside the shell (resizing may have made
-	 * it invalid) */
+	// Check that the cursor is inside the shell (resizing may have made
+	// it invalid)
 	if (gui.row >= screen_Rows || gui.col >= screen_Columns)
 	    return;
 
@@ -1147,7 +1146,7 @@
 	else
 	    id = shape->id;
 
-	/* get the colors and attributes for the cursor.  Default is inverted */
+	// get the colors and attributes for the cursor.  Default is inverted
 	cfg = INVALCOLOR;
 	cbg = INVALCOLOR;
 	cattr = HL_INVERSE;
@@ -1292,16 +1291,16 @@
 	    if (has_mbyte && (*mb_off2cells)(LineOffset[gui.row] + gui.col,
 				    LineOffset[gui.row] + screen_Columns) > 1)
 	    {
-		/* Double wide character. */
+		// Double wide character.
 		if (shape->shape != SHAPE_VER)
 		    cur_width += gui.char_width;
 #ifdef FEAT_RIGHTLEFT
 		if (CURSOR_BAR_RIGHT)
 		{
-		    /* gui.col points to the left halve of the character but
-		     * the vertical line needs to be on the right halve.
-		     * A double-wide horizontal line is also drawn from the
-		     * right halve in gui_mch_draw_part_cursor(). */
+		    // gui.col points to the left halve of the character but
+		    // the vertical line needs to be on the right halve.
+		    // A double-wide horizontal line is also drawn from the
+		    // right halve in gui_mch_draw_part_cursor().
 		    col_off = TRUE;
 		    ++gui.col;
 		}
@@ -1313,7 +1312,7 @@
 		--gui.col;
 #endif
 
-#ifndef FEAT_GUI_MSWIN	    /* doesn't seem to work for MSWindows */
+#ifndef FEAT_GUI_MSWIN	    // doesn't seem to work for MSWindows
 	    gui.highlight_mask = ScreenAttrs[LineOffset[gui.row] + gui.col];
 	    (void)gui_screenchar(LineOffset[gui.row] + gui.col,
 		    GUI_MON_TRS_CURSOR | GUI_MON_NOCLEAR,
@@ -1347,7 +1346,7 @@
     int	    text_area_width;
     int	    text_area_height;
 
-    /* avoid that moving components around generates events */
+    // avoid that moving components around generates events
     ++hold_gui_events;
 
     text_area_x = 0;
@@ -1436,9 +1435,9 @@
     if (gui.which_scrollbars[SBAR_BOTTOM])
 	base_height += gui.scrollbar_height;
 #ifdef FEAT_GUI_GTK
-    /* We can't take the sizes properly into account until anything is
-     * realized.  Therefore we recalculate all the values here just before
-     * setting the size. (--mdcki) */
+    // We can't take the sizes properly into account until anything is
+    // realized.  Therefore we recalculate all the values here just before
+    // setting the size. (--mdcki)
 #else
 # ifdef FEAT_MENU
     if (gui.menu_is_active)
@@ -1477,7 +1476,7 @@
 {
     static int	busy = FALSE;
 
-    if (!gui.shell_created)	    /* ignore when still initializing */
+    if (!gui.shell_created)	    // ignore when still initializing
 	return;
 
     /*
@@ -1496,7 +1495,7 @@
     new_pixel_height = 0;
     busy = TRUE;
 
-    /* Flush pending output before redrawing */
+    // Flush pending output before redrawing
     out_flush();
 
     gui.num_cols = (pixel_width - gui_get_base_width()) / gui.char_width;
@@ -1512,8 +1511,8 @@
     if (State == ASKMORE || State == CONFIRM)
 	gui.row = gui.num_rows;
 
-    /* Only comparing Rows and Columns may be sufficient, but let's stay on
-     * the safe side. */
+    // Only comparing Rows and Columns may be sufficient, but let's stay on
+    // the safe side.
     if (gui.num_rows != screen_Rows || gui.num_cols != screen_Columns
 	    || gui.num_rows != Rows || gui.num_cols != Columns)
 	shell_resized();
@@ -1526,9 +1525,9 @@
 
     busy = FALSE;
 
-    /* We may have been called again while redrawing the screen.
-     * Need to do it all again with the latest size then.  But only if the size
-     * actually changed. */
+    // We may have been called again while redrawing the screen.
+    // Need to do it all again with the latest size then.  But only if the size
+    // actually changed.
     if (new_pixel_height)
     {
 	if (pixel_width == new_pixel_width && pixel_height == new_pixel_height)
@@ -1552,8 +1551,8 @@
 gui_may_resize_shell(void)
 {
     if (new_pixel_height)
-	/* careful: gui_resize_shell() may postpone the resize again if we
-	 * were called indirectly by it */
+	// careful: gui_resize_shell() may postpone the resize again if we
+	// were called indirectly by it
 	gui_resize_shell(new_pixel_width, new_pixel_height);
 }
 
@@ -1576,7 +1575,7 @@
 gui_set_shellsize(
     int		mustset UNUSED,
     int		fit_to_display,
-    int		direction)		/* RESIZE_HOR, RESIZE_VER */
+    int		direction)		// RESIZE_HOR, RESIZE_VER
 {
     int		base_width;
     int		base_height;
@@ -1596,8 +1595,8 @@
 	return;
 
 #if defined(MSWIN) || defined(FEAT_GUI_GTK)
-    /* If not setting to a user specified size and maximized, calculate the
-     * number of characters that fit in the maximized window. */
+    // If not setting to a user specified size and maximized, calculate the
+    // number of characters that fit in the maximized window.
     if (!mustset && (vim_strchr(p_go, GO_KEEPWINSIZE) != NULL
 						       || gui_mch_maximized()))
     {
@@ -1609,7 +1608,7 @@
     base_width = gui_get_base_width();
     base_height = gui_get_base_height();
     if (fit_to_display)
-	/* Remember the original window position. */
+	// Remember the original window position.
 	(void)gui_mch_get_winpos(&x, &y);
 
     width = Columns * gui.char_width + base_width;
@@ -1640,7 +1639,7 @@
 #ifdef FEAT_GUI_GTK
 	if (did_adjust == 2 || (width + gui.char_width >= screen_w
 				     && height + gui.char_height >= screen_h))
-	    /* don't unmaximize if at maximum size */
+	    // don't unmaximize if at maximum size
 	    un_maximize = FALSE;
 #endif
     }
@@ -1655,8 +1654,8 @@
 #ifdef FEAT_GUI_GTK
     if (un_maximize)
     {
-	/* If the window size is smaller than the screen unmaximize the
-	 * window, otherwise resizing won't work. */
+	// If the window size is smaller than the screen unmaximize the
+	// window, otherwise resizing won't work.
 	gui_mch_get_screen_dimensions(&screen_w, &screen_h);
 	if ((width + gui.char_width < screen_w
 				   || height + gui.char_height * 2 < screen_h)
@@ -1670,9 +1669,9 @@
 
     if (fit_to_display && x >= 0 && y >= 0)
     {
-	/* Some window managers put the Vim window left of/above the screen.
-	 * Only change the position if it wasn't already negative before
-	 * (happens on MS-Windows with a secondary monitor). */
+	// Some window managers put the Vim window left of/above the screen.
+	// Only change the position if it wasn't already negative before
+	// (happens on MS-Windows with a secondary monitor).
 	gui_mch_update();
 	if (gui_mch_get_winpos(&x, &y) == OK && (x < 0 || y < 0))
 	    gui_mch_set_winpos(x < 0 ? 0 : x, y < 0 ? 0 : y);
@@ -1707,18 +1706,18 @@
     static void
 gui_start_highlight(int mask)
 {
-    if (mask > HL_ALL)		    /* highlight code */
+    if (mask > HL_ALL)		    // highlight code
 	gui.highlight_mask = mask;
-    else			    /* mask */
+    else			    // mask
 	gui.highlight_mask |= mask;
 }
 
     void
 gui_stop_highlight(int mask)
 {
-    if (mask > HL_ALL)		    /* highlight code */
+    if (mask > HL_ALL)		    // highlight code
 	gui.highlight_mask = HL_NORMAL;
-    else			    /* mask */
+    else			    // mask
 	gui.highlight_mask &= ~mask;
 }
 
@@ -1733,12 +1732,12 @@
     int	    row2,
     int	    col2)
 {
-    /* Clear the selection if we are about to write over it */
+    // Clear the selection if we are about to write over it
     clip_may_clear_selection(row1, row2);
 
     gui_mch_clear_block(row1, col1, row2, col2);
 
-    /* Invalidate cursor if it was in this block */
+    // Invalidate cursor if it was in this block
     if (       gui.cursor_row >= row1 && gui.cursor_row <= row2
 	    && gui.cursor_col >= col1 && gui.cursor_col <= col2)
 	gui.cursor_is_valid = FALSE;
@@ -1761,11 +1760,11 @@
 {
     char_u	*p;
     int		arg1 = 0, arg2 = 0;
-    int		force_cursor = FALSE;	/* force cursor update */
+    int		force_cursor = FALSE;	// force cursor update
     int		force_scrollbar = FALSE;
     static win_T	*old_curwin = NULL;
 
-/* #define DEBUG_GUI_WRITE */
+// #define DEBUG_GUI_WRITE
 #ifdef DEBUG_GUI_WRITE
     {
 	int i;
@@ -1810,19 +1809,19 @@
 	    }
 	    switch (*p)
 	    {
-		case 'C':	/* Clear screen */
+		case 'C':	// Clear screen
 		    clip_scroll_selection(9999);
 		    gui_mch_clear_all();
 		    gui.cursor_is_valid = FALSE;
 		    force_scrollbar = TRUE;
 		    break;
-		case 'M':	/* Move cursor */
+		case 'M':	// Move cursor
 		    gui_set_cursor(arg1, arg2);
 		    break;
-		case 's':	/* force cursor (shape) update */
+		case 's':	// force cursor (shape) update
 		    force_cursor = TRUE;
 		    break;
-		case 'R':	/* Set scroll region */
+		case 'R':	// Set scroll region
 		    if (arg1 < arg2)
 		    {
 			gui.scroll_region_top = arg1;
@@ -1834,7 +1833,7 @@
 			gui.scroll_region_bot = arg1;
 		    }
 		    break;
-		case 'V':	/* Set vertical scroll region */
+		case 'V':	// Set vertical scroll region
 		    if (arg1 < arg2)
 		    {
 			gui.scroll_region_left = arg1;
@@ -1846,33 +1845,33 @@
 			gui.scroll_region_right = arg1;
 		    }
 		    break;
-		case 'd':	/* Delete line */
+		case 'd':	// Delete line
 		    gui_delete_lines(gui.row, 1);
 		    break;
-		case 'D':	/* Delete lines */
+		case 'D':	// Delete lines
 		    gui_delete_lines(gui.row, arg1);
 		    break;
-		case 'i':	/* Insert line */
+		case 'i':	// Insert line
 		    gui_insert_lines(gui.row, 1);
 		    break;
-		case 'I':	/* Insert lines */
+		case 'I':	// Insert lines
 		    gui_insert_lines(gui.row, arg1);
 		    break;
-		case '$':	/* Clear to end-of-line */
+		case '$':	// Clear to end-of-line
 		    gui_clear_block(gui.row, gui.col, gui.row,
 							    (int)Columns - 1);
 		    break;
-		case 'h':	/* Turn on highlighting */
+		case 'h':	// Turn on highlighting
 		    gui_start_highlight(arg1);
 		    break;
-		case 'H':	/* Turn off highlighting */
+		case 'H':	// Turn off highlighting
 		    gui_stop_highlight(arg1);
 		    break;
-		case 'f':	/* flash the window (visual bell) */
+		case 'f':	// flash the window (visual bell)
 		    gui_mch_flash(arg1 == 0 ? 20 : arg1);
 		    break;
 		default:
-		    p = s + 1;	/* Skip the ESC */
+		    p = s + 1;	// Skip the ESC
 		    break;
 	    }
 	    len -= (int)(++p - s);
@@ -1880,9 +1879,9 @@
 	}
 	else if (
 #ifdef EBCDIC
-		CtrlChar(s[0]) != 0	/* Ctrl character */
+		CtrlChar(s[0]) != 0	// Ctrl character
 #else
-		s[0] < 0x20		/* Ctrl character */
+		s[0] < 0x20		// Ctrl character
 #endif
 #ifdef FEAT_SIGN_ICONS
 		&& s[0] != SIGN_BYTE
@@ -1892,7 +1891,7 @@
 #endif
 		)
 	{
-	    if (s[0] == '\n')		/* NL */
+	    if (s[0] == '\n')		// NL
 	    {
 		gui.col = 0;
 		if (gui.row < gui.scroll_region_bot)
@@ -1900,26 +1899,26 @@
 		else
 		    gui_delete_lines(gui.scroll_region_top, 1);
 	    }
-	    else if (s[0] == '\r')	/* CR */
+	    else if (s[0] == '\r')	// CR
 	    {
 		gui.col = 0;
 	    }
-	    else if (s[0] == '\b')	/* Backspace */
+	    else if (s[0] == '\b')	// Backspace
 	    {
 		if (gui.col)
 		    --gui.col;
 	    }
-	    else if (s[0] == Ctrl_L)	/* cursor-right */
+	    else if (s[0] == Ctrl_L)	// cursor-right
 	    {
 		++gui.col;
 	    }
-	    else if (s[0] == Ctrl_G)	/* Beep */
+	    else if (s[0] == Ctrl_G)	// Beep
 	    {
 		gui_mch_beep();
 	    }
-	    /* Other Ctrl character: shouldn't happen! */
+	    // Other Ctrl character: shouldn't happen!
 
-	    --len;	/* Skip this char */
+	    --len;	// Skip this char
 	    ++s;
 	}
 	else
@@ -1947,20 +1946,20 @@
 	}
     }
 
-    /* Postponed update of the cursor (won't work if "can_update_cursor" isn't
-     * set). */
+    // Postponed update of the cursor (won't work if "can_update_cursor" isn't
+    // set).
     if (force_cursor)
 	gui_update_cursor(TRUE, TRUE);
 
-    /* When switching to another window the dragging must have stopped.
-     * Required for GTK, dragged_sb isn't reset. */
+    // When switching to another window the dragging must have stopped.
+    // Required for GTK, dragged_sb isn't reset.
     if (old_curwin != curwin)
 	gui.dragged_sb = SBAR_NONE;
 
-    /* Update the scrollbars after clearing the screen or when switched
-     * to another window.
-     * Update the horizontal scrollbar always, it's difficult to check all
-     * situations where it might change. */
+    // Update the scrollbars after clearing the screen or when switched
+    // to another window.
+    // Update the horizontal scrollbar always, it's difficult to check all
+    // situations where it might change.
     if (force_scrollbar || old_curwin != curwin)
 	gui_update_scrollbars(force_scrollbar);
     else
@@ -1975,7 +1974,7 @@
     gui.dragged_sb = SBAR_NONE;
 #endif
 
-    gui_may_flush();		    /* In case vim decides to take a nap */
+    gui_may_flush();		    // In case vim decides to take a nap
 }
 
 /*
@@ -1988,7 +1987,7 @@
 {
     if (gui.in_use)
     {
-	/* Undraw the cursor now, we probably can't do it after the change. */
+	// Undraw the cursor now, we probably can't do it after the change.
 	if (undraw)
 	    gui_undraw_cursor();
 	can_update_cursor = FALSE;
@@ -1999,8 +1998,8 @@
 gui_can_update_cursor(void)
 {
     can_update_cursor = TRUE;
-    /* No need to update the cursor right now, there is always more output
-     * after scrolling. */
+    // No need to update the cursor right now, there is always more output
+    // after scrolling.
 }
 
 /*
@@ -2047,7 +2046,7 @@
     {
 	if (has_mbyte)
 	{
-	    /* Find out how many chars fit in the current line. */
+	    // Find out how many chars fit in the current line.
 	    cells = 0;
 	    for (this_len = 0; this_len < len; )
 	    {
@@ -2057,7 +2056,7 @@
 		this_len += (*mb_ptr2len)(s + this_len);
 	    }
 	    if (this_len > len)
-		this_len = len;	    /* don't include following composing char */
+		this_len = len;	    // don't include following composing char
 	}
 	else
 	    if (gui.col + len > Columns)
@@ -2069,11 +2068,11 @@
 					  0, (guicolor_T)0, (guicolor_T)0, 0);
 	s += this_len;
 	len -= this_len;
-	/* fill up for a double-width char that doesn't fit. */
+	// fill up for a double-width char that doesn't fit.
 	if (len > 0 && gui.col < Columns)
 	    (void)gui_outstr_nowrap((char_u *)" ", 1,
 					  0, (guicolor_T)0, (guicolor_T)0, 0);
-	/* The cursor may wrap to the next line. */
+	// The cursor may wrap to the next line.
 	if (gui.col >= Columns)
 	{
 	    gui.col = 0;
@@ -2089,20 +2088,20 @@
  */
     static int
 gui_screenchar(
-    int		off,	    /* Offset from start of screen */
+    int		off,	    // Offset from start of screen
     int		flags,
-    guicolor_T	fg,	    /* colors for cursor */
-    guicolor_T	bg,	    /* colors for cursor */
-    int		back)	    /* backup this many chars when using bold trick */
+    guicolor_T	fg,	    // colors for cursor
+    guicolor_T	bg,	    // colors for cursor
+    int		back)	    // backup this many chars when using bold trick
 {
     char_u	buf[MB_MAXBYTES + 1];
 
-    /* Don't draw right halve of a double-width UTF-8 char. "cannot happen" */
+    // Don't draw right halve of a double-width UTF-8 char. "cannot happen"
     if (enc_utf8 && ScreenLines[off] == 0)
 	return OK;
 
     if (enc_utf8 && ScreenLinesUC[off] != 0)
-	/* Draw UTF-8 multi-byte character. */
+	// Draw UTF-8 multi-byte character.
 	return gui_outstr_nowrap(buf, utfc_char2bytes(off, buf),
 							 flags, fg, bg, back);
 
@@ -2113,7 +2112,7 @@
 	return gui_outstr_nowrap(buf, 2, flags, fg, bg, back);
     }
 
-    /* Draw non-multi-byte character or DBCS character. */
+    // Draw non-multi-byte character or DBCS character.
     return gui_outstr_nowrap(ScreenLines + off,
 	    enc_dbcs ? (*mb_ptr2len)(ScreenLines + off) : 1,
 							 flags, fg, bg, back);
@@ -2127,31 +2126,31 @@
  */
     static int
 gui_screenstr(
-    int		off,	    /* Offset from start of screen */
-    int		len,	    /* string length in screen cells */
+    int		off,	    // Offset from start of screen
+    int		len,	    // string length in screen cells
     int		flags,
-    guicolor_T	fg,	    /* colors for cursor */
-    guicolor_T	bg,	    /* colors for cursor */
-    int		back)	    /* backup this many chars when using bold trick */
+    guicolor_T	fg,	    // colors for cursor
+    guicolor_T	bg,	    // colors for cursor
+    int		back)	    // backup this many chars when using bold trick
 {
     char_u  *buf;
     int	    outlen = 0;
     int	    i;
     int	    retval;
 
-    if (len <= 0) /* "cannot happen"? */
+    if (len <= 0) // "cannot happen"?
 	return OK;
 
     if (enc_utf8)
     {
 	buf = alloc(len * MB_MAXBYTES + 1);
 	if (buf == NULL)
-	    return OK; /* not much we could do here... */
+	    return OK; // not much we could do here...
 
 	for (i = off; i < off + len; ++i)
 	{
 	    if (ScreenLines[i] == 0)
-		continue; /* skip second half of double-width char */
+		continue; // skip second half of double-width char
 
 	    if (ScreenLinesUC[i] == 0)
 		buf[outlen++] = ScreenLines[i];
@@ -2159,7 +2158,7 @@
 		outlen += utfc_char2bytes(i, buf + outlen);
 	}
 
-	buf[outlen] = NUL; /* only to aid debugging */
+	buf[outlen] = NUL; // only to aid debugging
 	retval = gui_outstr_nowrap(buf, outlen, flags, fg, bg, back);
 	vim_free(buf);
 
@@ -2169,20 +2168,20 @@
     {
 	buf = alloc(len * 2 + 1);
 	if (buf == NULL)
-	    return OK; /* not much we could do here... */
+	    return OK; // not much we could do here...
 
 	for (i = off; i < off + len; ++i)
 	{
 	    buf[outlen++] = ScreenLines[i];
 
-	    /* handle double-byte single-width char */
+	    // handle double-byte single-width char
 	    if (ScreenLines[i] == 0x8e)
 		buf[outlen++] = ScreenLines2[i];
 	    else if (MB_BYTE2LEN(ScreenLines[i]) == 2)
 		buf[outlen++] = ScreenLines[++i];
 	}
 
-	buf[outlen] = NUL; /* only to aid debugging */
+	buf[outlen] = NUL; // only to aid debugging
 	retval = gui_outstr_nowrap(buf, outlen, flags, fg, bg, back);
 	vim_free(buf);
 
@@ -2194,7 +2193,7 @@
 				 flags, fg, bg, back);
     }
 }
-#endif /* FEAT_GUI_GTK */
+#endif // FEAT_GUI_GTK
 
 /*
  * Output the given string at the current cursor position.  If the string is
@@ -2214,9 +2213,9 @@
     char_u	*s,
     int		len,
     int		flags,
-    guicolor_T	fg,	    /* colors for cursor */
-    guicolor_T	bg,	    /* colors for cursor */
-    int		back)	    /* backup this many chars when using bold trick */
+    guicolor_T	fg,	    // colors for cursor
+    guicolor_T	bg,	    // colors for cursor
+    int		back)	    // backup this many chars when using bold trick
 {
     long_u	highlight_mask;
     long_u	hl_mask_todo;
@@ -2258,7 +2257,7 @@
 	if (*s == MULTISIGN_BYTE)
 	    multi_sign = TRUE;
 # endif
-	/* draw spaces instead */
+	// draw spaces instead
 	if (*curwin->w_p_scl == 'n' && *(curwin->w_p_scl + 1) == 'u' &&
 		(curwin->w_p_nu || curwin->w_p_rnu))
 	{
@@ -2283,7 +2282,7 @@
     if (gui.highlight_mask > HL_ALL)
     {
 	aep = syn_gui_attr2entry(gui.highlight_mask);
-	if (aep == NULL)	    /* highlighting not set */
+	if (aep == NULL)	    // highlighting not set
 	    highlight_mask = 0;
 	else
 	    highlight_mask = aep->ae_attr;
@@ -2293,7 +2292,7 @@
     hl_mask_todo = highlight_mask;
 
 #if !defined(FEAT_GUI_GTK)
-    /* Set the font */
+    // Set the font
     if (aep != NULL && aep->ae_u.gui.font != NOFONT)
 	font = aep->ae_u.gui.font;
 # ifdef FEAT_XFONTSET
@@ -2354,7 +2353,7 @@
 
     draw_flags = 0;
 
-    /* Set the color */
+    // Set the color
     bg_color = gui.back_pixel;
     if ((flags & GUI_MON_IS_CURSOR) && gui.in_focus)
     {
@@ -2401,12 +2400,12 @@
     }
     gui_mch_set_sp_color(sp_color);
 
-    /* Clear the selection if we are about to write over it */
+    // Clear the selection if we are about to write over it
     if (!(flags & GUI_MON_NOCLEAR))
 	clip_may_clear_selection(gui.row, gui.row);
 
 
-    /* If there's no bold font, then fake it */
+    // If there's no bold font, then fake it
     if (hl_mask_todo & (HL_BOLD | HL_STANDOUT))
 	draw_flags |= DRAW_BOLD;
 
@@ -2419,29 +2418,29 @@
 	return FAIL;
 
 #if defined(FEAT_GUI_GTK)
-    /* If there's no italic font, then fake it.
-     * For GTK2, we don't need a different font for italic style. */
+    // If there's no italic font, then fake it.
+    // For GTK2, we don't need a different font for italic style.
     if (hl_mask_todo & HL_ITALIC)
 	draw_flags |= DRAW_ITALIC;
 
-    /* Do we underline the text? */
+    // Do we underline the text?
     if (hl_mask_todo & HL_UNDERLINE)
 	draw_flags |= DRAW_UNDERL;
 
 #else
-    /* Do we underline the text? */
+    // Do we underline the text?
     if ((hl_mask_todo & HL_UNDERLINE) || (hl_mask_todo & HL_ITALIC))
 	draw_flags |= DRAW_UNDERL;
 #endif
-    /* Do we undercurl the text? */
+    // Do we undercurl the text?
     if (hl_mask_todo & HL_UNDERCURL)
 	draw_flags |= DRAW_UNDERC;
 
-    /* Do we strikethrough the text? */
+    // Do we strikethrough the text?
     if (hl_mask_todo & HL_STRIKETHROUGH)
 	draw_flags |= DRAW_STRIKE;
 
-    /* Do we draw transparently? */
+    // Do we draw transparently?
     if (flags & GUI_MON_TRS_CURSOR)
 	draw_flags |= DRAW_TRANSP;
 
@@ -2449,31 +2448,31 @@
      * Draw the text.
      */
 #ifdef FEAT_GUI_GTK
-    /* The value returned is the length in display cells */
+    // The value returned is the length in display cells
     len = gui_gtk2_draw_string(gui.row, col, s, len, draw_flags);
 #else
     if (enc_utf8)
     {
-	int	start;		/* index of bytes to be drawn */
-	int	cells;		/* cellwidth of bytes to be drawn */
-	int	thislen;	/* length of bytes to be drawn */
-	int	cn;		/* cellwidth of current char */
-	int	i;		/* index of current char */
-	int	c;		/* current char value */
-	int	cl;		/* byte length of current char */
-	int	comping;	/* current char is composing */
-	int	scol = col;	/* screen column */
-	int	curr_wide = FALSE;  /* use 'guifontwide' */
+	int	start;		// index of bytes to be drawn
+	int	cells;		// cellwidth of bytes to be drawn
+	int	thislen;	// length of bytes to be drawn
+	int	cn;		// cellwidth of current char
+	int	i;		// index of current char
+	int	c;		// current char value
+	int	cl;		// byte length of current char
+	int	comping;	// current char is composing
+	int	scol = col;	// screen column
+	int	curr_wide = FALSE;  // use 'guifontwide'
 	int	prev_wide = FALSE;
 	int	wide_changed;
 # ifdef MSWIN
-	int	sep_comp = FALSE;   /* Don't separate composing chars. */
+	int	sep_comp = FALSE;   // Don't separate composing chars.
 # else
-	int	sep_comp = TRUE;    /* Separate composing chars. */
+	int	sep_comp = TRUE;    // Separate composing chars.
 # endif
 
-	/* Break the string at a composing character, it has to be drawn on
-	 * top of the previous character. */
+	// Break the string at a composing character, it has to be drawn on
+	// top of the previous character.
 	start = 0;
 	cells = 0;
 	for (i = 0; i < len; i += cl)
@@ -2481,7 +2480,7 @@
 	    c = utf_ptr2char(s + i);
 	    cn = utf_char2cells(c);
 	    comping = utf_iscomposing(c);
-	    if (!comping)	/* count cells from non-composing chars */
+	    if (!comping)	// count cells from non-composing chars
 		cells += cn;
 	    if (!comping || sep_comp)
 	    {
@@ -2495,20 +2494,20 @@
 		    curr_wide = FALSE;
 	    }
 	    cl = utf_ptr2len(s + i);
-	    if (cl == 0)	/* hit end of string */
-		len = i + cl;	/* len must be wrong "cannot happen" */
+	    if (cl == 0)	// hit end of string
+		len = i + cl;	// len must be wrong "cannot happen"
 
 	    wide_changed = curr_wide != prev_wide;
 
-	    /* Print the string so far if it's the last character or there is
-	     * a composing character. */
+	    // Print the string so far if it's the last character or there is
+	    // a composing character.
 	    if (i + cl >= len || (comping && sep_comp && i > start)
 		    || wide_changed
 # if defined(FEAT_GUI_X11)
 		    || (cn > 1
 #  ifdef FEAT_XFONTSET
-			/* No fontset: At least draw char after wide char at
-			 * right position. */
+			// No fontset: At least draw char after wide char at
+			// right position.
 			&& fontset == NOFONTSET
 #  endif
 		       )
@@ -2531,8 +2530,8 @@
 		}
 		scol += cells;
 		cells = 0;
-		/* Adjust to not draw a character which width is changed
-		 * against with last one. */
+		// Adjust to not draw a character which width is changed
+		// against with last one.
 		if (wide_changed && !(comping && sep_comp))
 		{
 		    scol -= cn;
@@ -2540,8 +2539,8 @@
 		}
 
 # if defined(FEAT_GUI_X11)
-		/* No fontset: draw a space to fill the gap after a wide char
-		 * */
+		// No fontset: draw a space to fill the gap after a wide char
+		//
 		if (cn > 1 && (draw_flags & DRAW_TRANSP) == 0
 #  ifdef FEAT_XFONTSET
 			&& fontset == NOFONTSET
@@ -2551,11 +2550,11 @@
 							       1, draw_flags);
 # endif
 	    }
-	    /* Draw a composing char on top of the previous char. */
+	    // Draw a composing char on top of the previous char.
 	    if (comping && sep_comp)
 	    {
 # if defined(__APPLE_CC__) && TARGET_API_MAC_CARBON
-		/* Carbon ATSUI autodraws composing char over previous char */
+		// Carbon ATSUI autodraws composing char over previous char
 		gui_mch_draw_string(gui.row, scol, s + i, cl,
 						    draw_flags | DRAW_TRANSP);
 # else
@@ -2566,7 +2565,7 @@
 	    }
 	    prev_wide = curr_wide;
 	}
-	/* The stuff below assumes "len" is the length in screen columns. */
+	// The stuff below assumes "len" is the length in screen columns.
 	len = scol - col;
     }
     else
@@ -2574,23 +2573,23 @@
 	gui_mch_draw_string(gui.row, col, s, len, draw_flags);
 	if (enc_dbcs == DBCS_JPNU)
 	{
-	    /* Get the length in display cells, this can be different from the
-	     * number of bytes for "euc-jp". */
+	    // Get the length in display cells, this can be different from the
+	    // number of bytes for "euc-jp".
 	    len = mb_string2cells(s, len);
 	}
     }
-#endif /* !FEAT_GUI_GTK */
+#endif // !FEAT_GUI_GTK
 
     if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR)))
 	gui.col = col + len;
 
-    /* May need to invert it when it's part of the selection. */
+    // May need to invert it when it's part of the selection.
     if (flags & GUI_MON_NOCLEAR)
 	clip_may_redraw_selection(gui.row, col, len);
 
     if (!(flags & (GUI_MON_IS_CURSOR | GUI_MON_TRS_CURSOR)))
     {
-	/* Invalidate the old physical cursor position if we wrote over it */
+	// Invalidate the old physical cursor position if we wrote over it
 	if (gui.cursor_row == gui.row
 		&& gui.cursor_col >= col
 		&& gui.cursor_col < col + len)
@@ -2599,7 +2598,7 @@
 
 #ifdef FEAT_SIGN_ICONS
     if (draw_sign)
-	/* Draw the sign on top of the spaces. */
+	// Draw the sign on top of the spaces.
 	gui_mch_drawsign(gui.row, signcol, gui.highlight_mask);
 # if defined(FEAT_NETBEANS_INTG) && (defined(FEAT_GUI_X11) \
 	|| defined(FEAT_GUI_GTK) || defined(FEAT_GUI_MSWIN))
@@ -2670,7 +2669,7 @@
     int		col1,
     int		row2,
     int		col2,
-    int		flags)	/* flags for gui_outstr_nowrap() */
+    int		flags)	// flags for gui_outstr_nowrap()
 {
     int		old_row, old_col;
     long_u	old_hl_mask;
@@ -2681,18 +2680,18 @@
     int		retval = FALSE;
     int		orig_col1, orig_col2;
 
-    /* Don't try to update when ScreenLines is not valid */
+    // Don't try to update when ScreenLines is not valid
     if (!screen_cleared || ScreenLines == NULL)
 	return retval;
 
-    /* Don't try to draw outside the shell! */
-    /* Check everything, strange values may be caused by a big border width */
+    // Don't try to draw outside the shell!
+    // Check everything, strange values may be caused by a big border width
     col1 = check_col(col1);
     col2 = check_col(col2);
     row1 = check_row(row1);
     row2 = check_row(row2);
 
-    /* Remember where our cursor was */
+    // Remember where our cursor was
     old_row = gui.row;
     old_col = gui.col;
     old_hl_mask = gui.highlight_mask;
@@ -2701,8 +2700,8 @@
 
     for (gui.row = row1; gui.row <= row2; gui.row++)
     {
-	/* When only half of a double-wide character is in the block, include
-	 * the other half. */
+	// When only half of a double-wide character is in the block, include
+	// the other half.
 	col1 = orig_col1;
 	col2 = orig_col2;
 	off = LineOffset[gui.row];
@@ -2739,8 +2738,8 @@
 	off = LineOffset[gui.row] + gui.col;
 	len = col2 - col1 + 1;
 
-	/* Find how many chars back this highlighting starts, or where a space
-	 * is.  Needed for when the bold trick is used */
+	// Find how many chars back this highlighting starts, or where a space
+	// is.  Needed for when the bold trick is used
 	for (back = 0; back < col1; ++back)
 	    if (ScreenAttrs[off - 1 - back] != ScreenAttrs[off]
 		    || ScreenLines[off - 1 - back] == ' ')
@@ -2748,8 +2747,8 @@
 	retval = (col1 > 0 && ScreenAttrs[off - 1] != 0 && back == 0
 					      && ScreenLines[off - 1] != ' ');
 
-	/* Break it up in strings of characters with the same attributes. */
-	/* Print UTF-8 characters individually. */
+	// Break it up in strings of characters with the same attributes.
+	// Print UTF-8 characters individually.
 	while (len > 0)
 	{
 	    first_attr = ScreenAttrs[off];
@@ -2757,7 +2756,7 @@
 #if !defined(FEAT_GUI_GTK)
 	    if (enc_utf8 && ScreenLinesUC[off] != 0)
 	    {
-		/* output multi-byte character separately */
+		// output multi-byte character separately
 		nback = gui_screenchar(off, flags,
 					  (guicolor_T)0, (guicolor_T)0, back);
 		if (gui.col < Columns && ScreenLines[off + 1] == 0)
@@ -2767,7 +2766,7 @@
 	    }
 	    else if (enc_dbcs == DBCS_JPNU && ScreenLines[off] == 0x8e)
 	    {
-		/* output double-byte, single-width character separately */
+		// output double-byte, single-width character separately
 		nback = gui_screenchar(off, flags,
 					  (guicolor_T)0, (guicolor_T)0, back);
 		idx = 1;
@@ -2779,28 +2778,28 @@
 		for (idx = 0; idx < len; ++idx)
 		{
 		    if (enc_utf8 && ScreenLines[off + idx] == 0)
-			continue; /* skip second half of double-width char */
+			continue; // skip second half of double-width char
 		    if (ScreenAttrs[off + idx] != first_attr)
 			break;
 		}
-		/* gui_screenstr() takes care of multibyte chars */
+		// gui_screenstr() takes care of multibyte chars
 		nback = gui_screenstr(off, idx, flags,
 				      (guicolor_T)0, (guicolor_T)0, back);
 #else
 		for (idx = 0; idx < len && ScreenAttrs[off + idx] == first_attr;
 									idx++)
 		{
-		    /* Stop at a multi-byte Unicode character. */
+		    // Stop at a multi-byte Unicode character.
 		    if (enc_utf8 && ScreenLinesUC[off + idx] != 0)
 			break;
 		    if (enc_dbcs == DBCS_JPNU)
 		    {
-			/* Stop at a double-byte single-width char. */
+			// Stop at a double-byte single-width char.
 			if (ScreenLines[off + idx] == 0x8e)
 			    break;
 			if (len > 1 && (*mb_ptr2len)(ScreenLines
 							    + off + idx) == 2)
-			    ++idx;  /* skip second byte of double-byte char */
+			    ++idx;  // skip second byte of double-byte char
 		    }
 		}
 		nback = gui_outstr_nowrap(ScreenLines + off, idx, flags,
@@ -2809,8 +2808,8 @@
 	    }
 	    if (nback == FAIL)
 	    {
-		/* Must back up to start drawing where a bold or italic word
-		 * starts. */
+		// Must back up to start drawing where a bold or italic word
+		// starts.
 		off -= back;
 		len += back;
 		gui.col -= back;
@@ -2824,7 +2823,7 @@
 	}
     }
 
-    /* Put the cursor back where it was */
+    // Put the cursor back where it was
     gui.row = old_row;
     gui.col = old_col;
     gui.highlight_mask = (int)old_hl_mask;
@@ -2839,15 +2838,15 @@
 	return;
 
     if (row + count > gui.scroll_region_bot)
-	/* Scrolled out of region, just blank the lines out */
+	// Scrolled out of region, just blank the lines out
 	gui_clear_block(row, gui.scroll_region_left,
 			      gui.scroll_region_bot, gui.scroll_region_right);
     else
     {
 	gui_mch_delete_lines(row, count);
 
-	/* If the cursor was in the deleted lines it's now gone.  If the
-	 * cursor was in the scrolled lines adjust its position. */
+	// If the cursor was in the deleted lines it's now gone.  If the
+	// cursor was in the scrolled lines adjust its position.
 	if (gui.cursor_row >= row
 		&& gui.cursor_col >= gui.scroll_region_left
 		&& gui.cursor_col <= gui.scroll_region_right)
@@ -2867,7 +2866,7 @@
 	return;
 
     if (row + count > gui.scroll_region_bot)
-	/* Scrolled out of region, just blank the lines out */
+	// Scrolled out of region, just blank the lines out
 	gui_clear_block(row, gui.scroll_region_left,
 			      gui.scroll_region_bot, gui.scroll_region_right);
     else
@@ -2992,7 +2991,7 @@
 gui_inchar(
     char_u  *buf,
     int	    maxlen,
-    long    wtime,		/* milli seconds */
+    long    wtime,		// milli seconds
     int	    tb_change_cnt)
 {
     return gui_wait_for_chars_buf(buf, maxlen, wtime, tb_change_cnt);
@@ -3069,7 +3068,7 @@
 	    button_char = KE_MOUSERIGHT;
 button_set:
 	    {
-		/* Don't put events in the input queue now. */
+		// Don't put events in the input queue now.
 		if (hold_gui_events)
 		    return;
 
@@ -3077,8 +3076,8 @@
 		string[4] = KS_EXTRA;
 		string[5] = (int)button_char;
 
-		/* Pass the pointer coordinates of the scroll event so that we
-		 * know which window to scroll. */
+		// Pass the pointer coordinates of the scroll event so that we
+		// know which window to scroll.
 		row = gui_xy2colrow(x, y, &col);
 		string[6] = (char_u)(col / 128 + ' ' + 1);
 		string[7] = (char_u)(col % 128 + ' ' + 1);
@@ -3105,14 +3104,14 @@
     }
 
 #ifdef FEAT_CLIPBOARD
-    /* If a clipboard selection is in progress, handle it */
+    // If a clipboard selection is in progress, handle it
     if (clip_star.state == SELECT_IN_PROGRESS)
     {
 	clip_process_selection(button, X_2_COL(x), Y_2_ROW(y), repeated_click);
 	return;
     }
 
-    /* Determine which mouse settings to look for based on the current mode */
+    // Determine which mouse settings to look for based on the current mode
     switch (get_real_state())
     {
 	case NORMAL_BUSY:
@@ -3130,9 +3129,9 @@
 	case INSERT:
 	case INSERT+LANGMAP:	checkfor = MOUSE_INSERT;	break;
 	case ASKMORE:
-	case HITRETURN:		/* At the more- and hit-enter prompt pass the
-				   mouse event for a click on or below the
-				   message line. */
+	case HITRETURN:		// At the more- and hit-enter prompt pass the
+				// mouse event for a click on or below the
+				// message line.
 				if (Y_2_ROW(y) >= msg_row)
 				    checkfor = MOUSE_NORMAL;
 				else
@@ -3192,7 +3191,7 @@
      */
     if (!mouse_has(checkfor) || checkfor == MOUSE_COMMAND)
     {
-	/* Don't do modeless selection in Visual mode. */
+	// Don't do modeless selection in Visual mode.
 	if (checkfor != MOUSE_NONEF && VIsual_active && (State & NORMAL))
 	    return;
 
@@ -3207,9 +3206,9 @@
 	    modifiers &= ~ MOUSE_SHIFT;
 	}
 
-	/* If the selection is done, allow the right button to extend it.
-	 * If the selection is cleared, allow the right button to start it
-	 * from the cursor position. */
+	// If the selection is done, allow the right button to extend it.
+	// If the selection is cleared, allow the right button to start it
+	// from the cursor position.
 	if (button == MOUSE_RIGHT)
 	{
 	    if (clip_star.state == SELECT_CLEARED)
@@ -3230,14 +3229,14 @@
 							      repeated_click);
 	    did_clip = TRUE;
 	}
-	/* Allow the left button to start the selection */
+	// Allow the left button to start the selection
 	else if (button == MOUSE_LEFT)
 	{
 	    clip_start_selection(X_2_COL(x), Y_2_ROW(y), repeated_click);
 	    did_clip = TRUE;
 	}
 
-	/* Always allow pasting */
+	// Always allow pasting
 	if (button != MOUSE_MIDDLE)
 	{
 	    if (!mouse_has(checkfor) || button == MOUSE_RELEASE)
@@ -3252,7 +3251,7 @@
 	clip_clear_selection(&clip_star);
 #endif
 
-    /* Don't put events in the input queue now. */
+    // Don't put events in the input queue now.
     if (hold_gui_events)
 	return;
 
@@ -3266,7 +3265,7 @@
     {
 	if (row == prev_row && col == prev_col)
 	    return;
-	/* Dragging above the window, set "row" to -1 to cause a scroll. */
+	// Dragging above the window, set "row" to -1 to cause a scroll.
 	if (y < 0)
 	    row = -1;
     }
@@ -3283,7 +3282,7 @@
 	    )
 	repeated_click = FALSE;
 
-    string[0] = CSI;	/* this sequence is recognized by check_termcode() */
+    string[0] = CSI;	// this sequence is recognized by check_termcode()
     string[1] = KS_MOUSE;
     string[2] = KE_FILLER;
     if (button != MOUSE_DRAG && button != MOUSE_RELEASE)
@@ -3356,7 +3355,7 @@
 {
     char_u  bytes[sizeof(long_u)];
 
-    /* Don't put events in the input queue now. */
+    // Don't put events in the input queue now.
     if (hold_gui_events)
 	return;
 
@@ -3464,7 +3463,7 @@
 		break;
 #endif
 	    case GO_GREY:
-		/* make menu's have grey items, ignored here */
+		// make menu's have grey items, ignored here
 		break;
 #ifdef FEAT_TOOLBAR
 	    case GO_TOOLBAR:
@@ -3482,7 +3481,7 @@
 #endif
 		break;
 	    default:
-		/* Ignore options that are not supported */
+		// Ignore options that are not supported
 		break;
 	}
 
@@ -3500,13 +3499,13 @@
 #endif
 
 #ifdef FEAT_GUI_TABLINE
-	/* Update the GUI tab line, it may appear or disappear.  This may
-	 * cause the non-GUI tab line to disappear or appear. */
+	// Update the GUI tab line, it may appear or disappear.  This may
+	// cause the non-GUI tab line to disappear or appear.
 	using_tabline = gui_has_tabline();
 	if (!gui_mch_showing_tabline() != !using_tabline)
 	{
-	    /* We don't want a resize event change "Rows" here, save and
-	     * restore it.  Resizing is handled below. */
+	    // We don't want a resize event change "Rows" here, save and
+	    // restore it.  Resizing is handled below.
 	    i = Rows;
 	    gui_update_tabline();
 	    Rows = i;
@@ -3514,16 +3513,16 @@
 	    if (using_tabline)
 		fix_size = TRUE;
 	    if (!gui_use_tabline())
-		redraw_tabline = TRUE;    /* may draw non-GUI tab line */
+		redraw_tabline = TRUE;    // may draw non-GUI tab line
 	}
 #endif
 
 	for (i = 0; i < 3; i++)
 	{
-	    /* The scrollbar needs to be updated when it is shown/unshown and
-	     * when switching tab pages.  But the size only changes when it's
-	     * shown/unshown.  Thus we need two places to remember whether a
-	     * scrollbar is there or not. */
+	    // The scrollbar needs to be updated when it is shown/unshown and
+	    // when switching tab pages.  But the size only changes when it's
+	    // shown/unshown.  Thus we need two places to remember whether a
+	    // scrollbar is there or not.
 	    if (gui.which_scrollbars[i] != prev_which_scrollbars[i]
 		    || gui.which_scrollbars[i]
 					!= curtab->tp_prev_which_scrollbars[i])
@@ -3553,8 +3552,8 @@
 #ifdef FEAT_MENU
 	if (gui.menu_is_active != prev_menu_is_active)
 	{
-	    /* We don't want a resize event change "Rows" here, save and
-	     * restore it.  Resizing is handled below. */
+	    // We don't want a resize event change "Rows" here, save and
+	    // restore it.  Resizing is handled below.
 	    i = Rows;
 	    gui_mch_enable_menu(gui.menu_is_active);
 	    Rows = i;
@@ -3598,22 +3597,22 @@
 	    long    prev_Columns = Columns;
 	    long    prev_Rows = Rows;
 #endif
-	    /* Adjust the size of the window to make the text area keep the
-	     * same size and to avoid that part of our window is off-screen
-	     * and a scrollbar can't be used, for example. */
+	    // Adjust the size of the window to make the text area keep the
+	    // same size and to avoid that part of our window is off-screen
+	    // and a scrollbar can't be used, for example.
 	    gui_set_shellsize(FALSE, fix_size, need_set_size);
 
 #ifdef FEAT_GUI_GTK
-	    /* GTK has the annoying habit of sending us resize events when
-	     * changing the window size ourselves.  This mostly happens when
-	     * waiting for a character to arrive, quite unpredictably, and may
-	     * change Columns and Rows when we don't want it.  Wait for a
-	     * character here to avoid this effect.
-	     * If you remove this, please test this command for resizing
-	     * effects (with optional left scrollbar): ":vsp|q|vsp|q|vsp|q".
-	     * Don't do this while starting up though.
-	     * Don't change Rows when adding menu/toolbar/tabline.
-	     * Don't change Columns when adding vertical toolbar. */
+	    // GTK has the annoying habit of sending us resize events when
+	    // changing the window size ourselves.  This mostly happens when
+	    // waiting for a character to arrive, quite unpredictably, and may
+	    // change Columns and Rows when we don't want it.  Wait for a
+	    // character here to avoid this effect.
+	    // If you remove this, please test this command for resizing
+	    // effects (with optional left scrollbar): ":vsp|q|vsp|q|vsp|q".
+	    // Don't do this while starting up though.
+	    // Don't change Rows when adding menu/toolbar/tabline.
+	    // Don't change Columns when adding vertical toolbar.
 	    if (!gui.starting && need_set_size != (RESIZE_VERT | RESIZE_HOR))
 		(void)char_avail();
 	    if ((need_set_size & RESIZE_VERT) == 0)
@@ -3622,10 +3621,10 @@
 		Columns = prev_Columns;
 #endif
 	}
-	/* When the console tabline appears or disappears the window positions
-	 * change. */
+	// When the console tabline appears or disappears the window positions
+	// change.
 	if (firstwin->w_winrow != tabline_height())
-	    shell_new_rows();	/* recompute window positions and heights */
+	    shell_new_rows();	// recompute window positions and heights
     }
 }
 
@@ -3666,8 +3665,8 @@
 
     if (!gui.starting && starting == 0)
     {
-	/* Updating the tabline uses direct GUI commands, flush
-	 * outstanding instructions first. (esp. clear screen) */
+	// Updating the tabline uses direct GUI commands, flush
+	// outstanding instructions first. (esp. clear screen)
 	out_flush();
 
 	if (!showit != !shown)
@@ -3675,8 +3674,8 @@
 	if (showit != 0)
 	    gui_mch_update_tabline();
 
-	/* When the tabs change from hidden to shown or from shown to
-	 * hidden the size of the text area should remain the same. */
+	// When the tabs change from hidden to shown or from shown to
+	// hidden the size of the text area should remain the same.
 	if (!showit != !shown)
 	    gui_set_shellsize(FALSE, showit, RESIZE_VERT);
     }
@@ -3688,7 +3687,7 @@
     void
 get_tabline_label(
     tabpage_T	*tp,
-    int		tooltip)	/* TRUE: get tooltip */
+    int		tooltip)	// TRUE: get tooltip
 {
     int		modified = FALSE;
     char_u	buf[40];
@@ -3696,7 +3695,7 @@
     win_T	*wp;
     char_u	**opt;
 
-    /* Use 'guitablabel' or 'guitabtooltip' if it's set. */
+    // Use 'guitablabel' or 'guitabtooltip' if it's set.
     opt = (tooltip ? &p_gtt : &p_gtl);
     if (**opt != NUL)
     {
@@ -3714,7 +3713,7 @@
 	set_vim_var_nr(VV_LNUM, printer_page_num);
 	use_sandbox = was_set_insecurely(opt_name, 0);
 # endif
-	/* It's almost as going to the tabpage, but without autocommands. */
+	// It's almost as going to the tabpage, but without autocommands.
 	curtab->tp_firstwin = firstwin;
 	curtab->tp_lastwin = lastwin;
 	curtab->tp_curwin = curwin;
@@ -3726,12 +3725,12 @@
 	curwin = curtab->tp_curwin;
 	curbuf = curwin->w_buffer;
 
-	/* Can't use NameBuff directly, build_stl_str_hl() uses it. */
+	// Can't use NameBuff directly, build_stl_str_hl() uses it.
 	build_stl_str_hl(curwin, res, MAXPATHL, *opt, use_sandbox,
 						 0, (int)Columns, NULL, NULL);
 	STRCPY(NameBuff, res);
 
-	/* Back to the original curtab. */
+	// Back to the original curtab.
 	curtab = save_curtab;
 	topframe = curtab->tp_topframe;
 	firstwin = curtab->tp_firstwin;
@@ -3745,11 +3744,11 @@
 	called_emsg |= save_called_emsg;
     }
 
-    /* If 'guitablabel'/'guitabtooltip' is not set or the result is empty then
-     * use a default label. */
+    // If 'guitablabel'/'guitabtooltip' is not set or the result is empty then
+    // use a default label.
     if (**opt == NUL || *NameBuff == NUL)
     {
-	/* Get the buffer name into NameBuff[] and shorten it. */
+	// Get the buffer name into NameBuff[] and shorten it.
 	get_trans_bufname(tp == curtab ? curbuf : tp->tp_curwin->w_buffer);
 	if (!tooltip)
 	    shorten_dir(NameBuff);
@@ -3786,14 +3785,14 @@
     if (nr == tabpage_index(curtab))
 	return FALSE;
 
-    /* Don't put events in the input queue now. */
+    // Don't put events in the input queue now.
     if (hold_gui_events
 # ifdef FEAT_CMDWIN
 	    || cmdwin_type != 0
 # endif
 	    )
     {
-	/* Set it back to the current tab page. */
+	// Set it back to the current tab page.
 	gui_mch_set_curtab(tabpage_index(curtab));
 	return FALSE;
     }
@@ -3865,7 +3864,7 @@
 {
     static int	sbar_ident = 0;
 
-    sb->ident = sbar_ident++;	/* No check for too big, but would it happen? */
+    sb->ident = sbar_ident++;	// No check for too big, but would it happen?
     sb->wp = wp;
     sb->type = type;
     sb->value = 0;
@@ -3935,7 +3934,7 @@
     if (sb == NULL)
 	return;
 
-    /* Don't put events in the input queue now. */
+    // Don't put events in the input queue now.
     if (hold_gui_events)
 	return;
 
@@ -3958,13 +3957,13 @@
     {
 	gui.dragged_sb = SBAR_NONE;
 #ifdef FEAT_GUI_GTK
-	/* Keep the "dragged_wp" value until after the scrolling, for when the
-	 * mouse button is released.  GTK2 doesn't send the button-up event. */
+	// Keep the "dragged_wp" value until after the scrolling, for when the
+	// mouse button is released.  GTK2 doesn't send the button-up event.
 	gui.dragged_wp = NULL;
 #endif
     }
 
-    /* Vertical sbar info is kept in the first sbar (the left one) */
+    // Vertical sbar info is kept in the first sbar (the left one)
     if (sb->wp != NULL)
 	sb = &sb->wp->w_scrollbars[0];
 
@@ -3984,14 +3983,14 @@
     sb->value = value;
 
 #ifdef USE_ON_FLY_SCROLL
-    /* When not allowed to do the scrolling right now, return.
-     * This also checked input_available(), but that causes the first click in
-     * a scrollbar to be ignored when Vim doesn't have focus. */
+    // When not allowed to do the scrolling right now, return.
+    // This also checked input_available(), but that causes the first click in
+    // a scrollbar to be ignored when Vim doesn't have focus.
     if (dont_scroll)
 	return;
 #endif
-    /* Disallow scrolling the current window when the completion popup menu is
-     * visible. */
+    // Disallow scrolling the current window when the completion popup menu is
+    // visible.
     if ((sb->wp == NULL || sb->wp == curwin) && pum_visible())
 	return;
 
@@ -4004,7 +4003,7 @@
     }
 #endif
 
-    if (sb->wp != NULL)		/* vertical scrollbar */
+    if (sb->wp != NULL)		// vertical scrollbar
     {
 	sb_num = 0;
 	for (wp = firstwin; wp != sb->wp && wp != NULL; wp = wp->w_next)
@@ -4034,12 +4033,12 @@
 	    }
 	}
 # ifdef FEAT_FOLDING
-	/* Value may have been changed for closed fold. */
+	// Value may have been changed for closed fold.
 	sb->value = sb->wp->w_topline - 1;
 # endif
 
-	/* When dragging one scrollbar and there is another one at the other
-	 * side move the thumb of that one too. */
+	// When dragging one scrollbar and there is another one at the other
+	// side move the thumb of that one too.
 	if (gui.which_scrollbars[SBAR_RIGHT] && gui.which_scrollbars[SBAR_LEFT])
 	    gui_mch_set_scrollbar_thumb(
 		    &sb->wp->w_scrollbars[
@@ -4074,7 +4073,7 @@
 	}
 	if (old_leftcol != curwin->w_leftcol)
 	{
-	    updateWindow(curwin);   /* update window, status and cmdline */
+	    updateWindow(curwin);   // update window, status and cmdline
 	    setcursor();
 	}
 #else
@@ -4098,7 +4097,7 @@
 			))))
     {
 	do_check_scrollbind(TRUE);
-	/* need to update the window right here */
+	// need to update the window right here
 	FOR_ALL_WINDOWS(wp)
 	    if (wp->w_redr_type > 0)
 		updateWindow(wp);
@@ -4133,21 +4132,21 @@
 
     void
 gui_update_scrollbars(
-    int		force)	    /* Force all scrollbars to get updated */
+    int		force)	    // Force all scrollbars to get updated
 {
     win_T	*wp;
     scrollbar_T	*sb;
-    long	val, size, max;		/* need 32 bits here */
+    long	val, size, max;		// need 32 bits here
     int		which_sb;
     int		h, y;
     static win_T *prev_curwin = NULL;
 
-    /* Update the horizontal scrollbar */
+    // Update the horizontal scrollbar
     gui_update_horiz_scrollbar(force);
 
 #ifndef MSWIN
-    /* Return straight away if there is neither a left nor right scrollbar.
-     * On MS-Windows this is required anyway for scrollwheel messages. */
+    // Return straight away if there is neither a left nor right scrollbar.
+    // On MS-Windows this is required anyway for scrollwheel messages.
     if (!gui.which_scrollbars[SBAR_LEFT] && !gui.which_scrollbars[SBAR_RIGHT])
 	return;
 #endif
@@ -4174,14 +4173,14 @@
 		    gui.dragged_wp->w_scrollbars[0].max);
     }
 
-    /* avoid that moving components around generates events */
+    // avoid that moving components around generates events
     ++hold_gui_events;
 
     for (wp = firstwin; wp != NULL; wp = W_NEXT(wp))
     {
-	if (wp->w_buffer == NULL)	/* just in case */
+	if (wp->w_buffer == NULL)	// just in case
 	    continue;
-	/* Skip a scrollbar that is being dragged. */
+	// Skip a scrollbar that is being dragged.
 	if (!force && (gui.dragged_sb == SBAR_LEFT
 					     || gui.dragged_sb == SBAR_RIGHT)
 		&& gui.dragged_wp == wp)
@@ -4192,20 +4191,20 @@
 #else
 	max = wp->w_buffer->b_ml.ml_line_count + wp->w_height - 2;
 #endif
-	if (max < 0)			/* empty buffer */
+	if (max < 0)			// empty buffer
 	    max = 0;
 	val = wp->w_topline - 1;
 	size = wp->w_height;
 #ifdef SCROLL_PAST_END
-	if (val > max)			/* just in case */
+	if (val > max)			// just in case
 	    val = max;
 #else
-	if (size > max + 1)		/* just in case */
+	if (size > max + 1)		// just in case
 	    size = max + 1;
 	if (val > max - size + 1)
 	    val = max - size + 1;
 #endif
-	if (val < 0)			/* minimal value is 0 */
+	if (val < 0)			// minimal value is 0
 	    val = 0;
 
 	/*
@@ -4225,7 +4224,7 @@
 	     * This can happen during changing files.  Just don't update the
 	     * scrollbar for now.
 	     */
-	    sb->height = 0;	    /* Force update next time */
+	    sb->height = 0;	    // Force update next time
 	    if (gui.which_scrollbars[SBAR_LEFT])
 		gui_do_scrollbar(wp, SBAR_LEFT, FALSE);
 	    if (gui.which_scrollbars[SBAR_RIGHT])
@@ -4238,14 +4237,14 @@
 	    || sb->width != wp->w_width
 	    || prev_curwin != curwin)
 	{
-	    /* Height, width or position of scrollbar has changed.  For
-	     * vertical split: curwin changed. */
+	    // Height, width or position of scrollbar has changed.  For
+	    // vertical split: curwin changed.
 	    sb->height = wp->w_height;
 	    sb->top = wp->w_winrow;
 	    sb->status_height = wp->w_status_height;
 	    sb->width = wp->w_width;
 
-	    /* Calculate height and position in pixels */
+	    // Calculate height and position in pixels
 	    h = (sb->height + sb->status_height) * gui.char_height;
 	    y = sb->top * gui.char_height + gui.border_offset;
 #if defined(FEAT_MENU) && !defined(FEAT_GUI_GTK) && !defined(FEAT_GUI_MOTIF) && !defined(FEAT_GUI_PHOTON)
@@ -4271,7 +4270,7 @@
 
 	    if (wp->w_winrow == 0)
 	    {
-		/* Height of top scrollbar includes width of top border */
+		// Height of top scrollbar includes width of top border
 		h += gui.border_offset;
 		y -= gui.border_offset;
 	    }
@@ -4291,10 +4290,10 @@
 	    }
 	}
 
-	/* Reduce the number of calls to gui_mch_set_scrollbar_thumb() by
-	 * checking if the thumb moved at least a pixel.  Only do this for
-	 * Athena, most other GUIs require the update anyway to make the
-	 * arrows work. */
+	// Reduce the number of calls to gui_mch_set_scrollbar_thumb() by
+	// checking if the thumb moved at least a pixel.  Only do this for
+	// Athena, most other GUIs require the update anyway to make the
+	// arrows work.
 #ifdef FEAT_GUI_ATHENA
 	if (max == 0)
 	    y = 0;
@@ -4305,7 +4304,7 @@
 	if (force || sb->value != val || sb->size != size || sb->max != max)
 #endif
 	{
-	    /* Thumb of scrollbar has moved */
+	    // Thumb of scrollbar has moved
 	    sb->value = val;
 #ifdef FEAT_GUI_ATHENA
 	    sb->pixval = y;
@@ -4334,27 +4333,27 @@
     static void
 gui_do_scrollbar(
     win_T	*wp,
-    int		which,	    /* SBAR_LEFT or SBAR_RIGHT */
-    int		enable)	    /* TRUE to enable scrollbar */
+    int		which,	    // SBAR_LEFT or SBAR_RIGHT
+    int		enable)	    // TRUE to enable scrollbar
 {
     int		midcol = curwin->w_wincol + curwin->w_width / 2;
     int		has_midcol = (wp->w_wincol <= midcol
 				     && wp->w_wincol + wp->w_width >= midcol);
 
-    /* Only enable scrollbars that contain the middle column of the current
-     * window. */
+    // Only enable scrollbars that contain the middle column of the current
+    // window.
     if (gui.which_scrollbars[SBAR_RIGHT] != gui.which_scrollbars[SBAR_LEFT])
     {
-	/* Scrollbars only on one side.  Don't enable scrollbars that don't
-	 * contain the middle column of the current window. */
+	// Scrollbars only on one side.  Don't enable scrollbars that don't
+	// contain the middle column of the current window.
 	if (!has_midcol)
 	    enable = FALSE;
     }
     else
     {
-	/* Scrollbars on both sides.  Don't enable scrollbars that neither
-	 * contain the middle column of the current window nor are on the far
-	 * side. */
+	// Scrollbars on both sides.  Don't enable scrollbars that neither
+	// contain the middle column of the current window nor are on the far
+	// side.
 	if (midcol > Columns / 2)
 	{
 	    if (which == SBAR_LEFT ? wp->w_wincol != 0 : !has_midcol)
@@ -4391,7 +4390,7 @@
 	if (wp == NULL)
 	    break;
     if (wp == NULL)
-	/* Couldn't find window */
+	// Couldn't find window
 	return FALSE;
 
     /*
@@ -4413,9 +4412,9 @@
 	scrolldown(-nlines, gui.dragged_wp == NULL);
     else
 	scrollup(nlines, gui.dragged_wp == NULL);
-    /* Reset dragged_wp after using it.  "dragged_sb" will have been reset for
-     * the mouse-up event already, but we still want it to behave like when
-     * dragging.  But not the next click in an arrow. */
+    // Reset dragged_wp after using it.  "dragged_sb" will have been reset for
+    // the mouse-up event already, but we still want it to behave like when
+    // dragging.  But not the next click in an arrow.
     if (gui.dragged_sb == SBAR_NONE)
 	gui.dragged_wp = NULL;
 
@@ -4427,15 +4426,15 @@
     {
 	if (get_scrolloff_value() != 0)
 	{
-	    cursor_correct();		/* fix window for 'so' */
-	    update_topline();		/* avoid up/down jump */
+	    cursor_correct();		// fix window for 'so'
+	    update_topline();		// avoid up/down jump
 	}
 	if (old_cursor.lnum != wp->w_cursor.lnum)
 	    coladvance(wp->w_curswant);
 	wp->w_scbind_pos = wp->w_topline;
     }
 
-    /* Make sure wp->w_leftcol and wp->w_skipcol are correct. */
+    // Make sure wp->w_leftcol and wp->w_skipcol are correct.
     validate_cursor();
 
     curwin = save_wp;
@@ -4460,16 +4459,16 @@
 	    wp->w_lines_valid = 0;
 	}
 
-	/* Don't set must_redraw here, it may cause the popup menu to
-	 * disappear when losing focus after a scrollbar drag. */
+	// Don't set must_redraw here, it may cause the popup menu to
+	// disappear when losing focus after a scrollbar drag.
 	if (wp->w_redr_type < type)
 	    wp->w_redr_type = type;
 	mch_disable_flush();
-	updateWindow(wp);   /* update window, status line, and cmdline */
+	updateWindow(wp);   // update window, status line, and cmdline
 	mch_enable_flush();
     }
 
-    /* May need to redraw the popup menu. */
+    // May need to redraw the popup menu.
     if (pum_visible())
 	pum_redraw();
 
@@ -4498,15 +4497,15 @@
 	{
 	    w = chartabsize(p, col);
 	    MB_PTR_ADV(p);
-	    if (*p == NUL)		/* don't count the last character */
+	    if (*p == NUL)		// don't count the last character
 		break;
 	    col += w;
 	}
     return col;
 }
 
-/* Remember which line is currently the longest, so that we don't have to
- * search for it when scrolling horizontally. */
+// Remember which line is currently the longest, so that we don't have to
+// search for it when scrolling horizontally.
 static linenr_T longest_lnum = 0;
 
 /*
@@ -4518,9 +4517,9 @@
 {
     linenr_T ret = 0;
 
-    /* Calculate maximum for horizontal scrollbar.  Check for reasonable
-     * line numbers, topline and botline can be invalid when displaying is
-     * postponed. */
+    // Calculate maximum for horizontal scrollbar.  Check for reasonable
+    // line numbers, topline and botline can be invalid when displaying is
+    // postponed.
     if (vim_strchr(p_go, GO_HORSCROLL) == NULL
 	    && curwin->w_topline <= curwin->w_cursor.lnum
 	    && curwin->w_botline > curwin->w_cursor.lnum
@@ -4530,9 +4529,9 @@
 	colnr_T	    n;
 	long	    max = 0;
 
-	/* Use maximum of all visible lines.  Remember the lnum of the
-	 * longest line, closest to the cursor line.  Used when scrolling
-	 * below. */
+	// Use maximum of all visible lines.  Remember the lnum of the
+	// longest line, closest to the cursor line.  Used when scrolling
+	// below.
 	for (lnum = curwin->w_topline; lnum < curwin->w_botline; ++lnum)
 	{
 	    n = scroll_line_len(lnum);
@@ -4548,7 +4547,7 @@
 	}
     }
     else
-	/* Use cursor line only. */
+	// Use cursor line only.
 	ret = curwin->w_cursor.lnum;
 
     return ret;
@@ -4557,7 +4556,7 @@
     static void
 gui_update_horiz_scrollbar(int force)
 {
-    long	value, size, max;	/* need 32 bit ints here */
+    long	value, size, max;	// need 32 bit ints here
 
     if (!gui.which_scrollbars[SBAR_BOTTOM])
 	return;
@@ -4597,7 +4596,7 @@
 
 	if (virtual_active())
 	{
-	    /* May move the cursor even further to the right. */
+	    // May move the cursor even further to the right.
 	    if (curwin->w_virtcol >= (colnr_T)max)
 		max = curwin->w_virtcol;
 	}
@@ -4605,8 +4604,8 @@
 #ifndef SCROLL_PAST_END
 	max += curwin->w_width - 1;
 #endif
-	/* The line number isn't scrolled, thus there is less space when
-	 * 'number' or 'relativenumber' is set (also for 'foldcolumn'). */
+	// The line number isn't scrolled, thus there is less space when
+	// 'number' or 'relativenumber' is set (also for 'foldcolumn').
 	size -= curwin_col_off();
 #ifndef SCROLL_PAST_END
 	max -= curwin_col_off();
@@ -4615,7 +4614,7 @@
 
 #ifndef SCROLL_PAST_END
     if (value > max - size + 1)
-	value = max - size + 1;	    /* limit the value to allowable range */
+	value = max - size + 1;	    // limit the value to allowable range
 #endif
 
 #ifdef FEAT_RIGHTLEFT
@@ -4647,7 +4646,7 @@
     int
 gui_do_horiz_scroll(long_u leftcol, int compute_longest_lnum)
 {
-    /* no wrapping, no scrolling */
+    // no wrapping, no scrolling
     if (curwin->w_p_wrap)
 	return FALSE;
 
@@ -4656,8 +4655,8 @@
 
     curwin->w_leftcol = (colnr_T)leftcol;
 
-    /* When the line of the cursor is too short, move the cursor to the
-     * longest visible line. */
+    // When the line of the cursor is too short, move the cursor to the
+    // longest visible line.
     if (vim_strchr(p_go, GO_HORSCROLL) == NULL
 	    && !virtual_active()
 	    && (colnr_T)leftcol > scroll_line_len(curwin->w_cursor.lnum))
@@ -4667,7 +4666,7 @@
 	    curwin->w_cursor.lnum = gui_find_longest_lnum();
 	    curwin->w_cursor.col = 0;
 	}
-	/* Do a sanity check on "longest_lnum", just in case. */
+	// Do a sanity check on "longest_lnum", just in case.
 	else if (longest_lnum >= curwin->w_topline
 		&& longest_lnum < curwin->w_botline)
 	{
@@ -4756,8 +4755,8 @@
     void
 init_gui_options(void)
 {
-    /* Set the 'background' option according to the lightness of the
-     * background color, unless the user has set it already. */
+    // Set the 'background' option according to the lightness of the
+    // background color, unless the user has set it already.
     if (!option_was_set((char_u *)"bg") && STRCMP(p_bg, gui_bg_default()) != 0)
     {
 	set_option_value((char_u *)"bg", 0L, gui_bg_default(), 0);
@@ -4771,7 +4770,7 @@
 {
     win_T	*wp;
 
-    /* Nothing to do if GUI hasn't started yet. */
+    // Nothing to do if GUI hasn't started yet.
     if (!gui.in_use)
 	return;
 
@@ -4802,9 +4801,9 @@
     xim_set_focus(in_focus);
 # endif
 
-    /* Put events in the input queue only when allowed.
-     * ui_focus_change() isn't called directly, because it invokes
-     * autocommands and that must not happen asynchronously. */
+    // Put events in the input queue only when allowed.
+    // ui_focus_change() isn't called directly, because it invokes
+    // autocommands and that must not happen asynchronously.
     if (!hold_gui_events)
     {
 	char_u  bytes[3];
@@ -4828,29 +4827,29 @@
     char_u	st[8];
 
 #ifdef FEAT_MOUSESHAPE
-    /* Get window pointer, and update mouse shape as well. */
+    // Get window pointer, and update mouse shape as well.
     wp = xy2win(x, y, IGNORE_POPUP);
 #endif
 
-    /* Only handle this when 'mousefocus' set and ... */
+    // Only handle this when 'mousefocus' set and ...
     if (p_mousef
-	    && !hold_gui_events		/* not holding events */
-	    && (State & (NORMAL|INSERT))/* Normal/Visual/Insert mode */
-	    && State != HITRETURN	/* but not hit-return prompt */
-	    && msg_scrolled == 0	/* no scrolled message */
-	    && !need_mouse_correct	/* not moving the pointer */
-	    && gui.in_focus)		/* gvim in focus */
+	    && !hold_gui_events		// not holding events
+	    && (State & (NORMAL|INSERT))// Normal/Visual/Insert mode
+	    && State != HITRETURN	// but not hit-return prompt
+	    && msg_scrolled == 0	// no scrolled message
+	    && !need_mouse_correct	// not moving the pointer
+	    && gui.in_focus)		// gvim in focus
     {
-	/* Don't move the mouse when it's left or right of the Vim window */
+	// Don't move the mouse when it's left or right of the Vim window
 	if (x < 0 || x > Columns * gui.char_width)
 	    return;
 #ifndef FEAT_MOUSESHAPE
 	wp = xy2win(x, y, IGNORE_POPUP);
 #endif
 	if (wp == curwin || wp == NULL)
-	    return;	/* still in the same old window, or none at all */
+	    return;	// still in the same old window, or none at all
 
-	/* Ignore position in the tab pages line. */
+	// Ignore position in the tab pages line.
 	if (Y_2_ROW(y) < tabline_height())
 	    return;
 
@@ -4862,7 +4861,7 @@
 	 */
 	if (finish_op)
 	{
-	    /* abort the current operator first */
+	    // abort the current operator first
 	    st[0] = ESC;
 	    add_to_input_buf(st, 1);
 	}
@@ -4878,7 +4877,7 @@
 	st[3] = (char_u)MOUSE_RELEASE;
 	add_to_input_buf(st, 8);
 #ifdef FEAT_GUI_GTK
-	/* Need to wake up the main loop */
+	// Need to wake up the main loop
 	if (gtk_main_level() > 0)
 	    gtk_main_quit();
 #endif
@@ -4937,7 +4936,7 @@
     need_mouse_correct = FALSE;
 
     wp = gui_mouse_window(IGNORE_POPUP);
-    if (wp != curwin && wp != NULL)	/* If in other than current window */
+    if (wp != curwin && wp != NULL)	// If in other than current window
     {
 	validate_cline_row();
 	gui_mch_setmouse((int)W_ENDCOL(curwin) * gui.char_width - 3,
@@ -4959,7 +4958,7 @@
 
     row = Y_2_ROW(y);
     col = X_2_COL(x);
-    if (row < 0 || col < 0)		/* before first window */
+    if (row < 0 || col < 0)		// before first window
 	return NULL;
     wp = mouse_find_win(&row, &col, popup);
     if (wp == NULL)
@@ -4972,7 +4971,7 @@
 	else
 	    update_mouseshape(SHAPE_IDX_MORE);
     }
-    else if (row > wp->w_height)	/* below status line */
+    else if (row > wp->w_height)	// below status line
 	update_mouseshape(SHAPE_IDX_CLINE);
     else if (!(State & CMDLINE) && wp->w_vsep_width > 0 && col == wp->w_width
 	    && (row != wp->w_height || !stl_connected(wp)) && msg_scrolled == 0)
@@ -5013,8 +5012,8 @@
 	emsg(_(e_nogvim));
 	return;
 #else
-	/* Clear the command.  Needed for when forking+exiting, to avoid part
-	 * of the argument ending up after the shell prompt. */
+	// Clear the command.  Needed for when forking+exiting, to avoid part
+	// of the argument ending up after the shell prompt.
 	msg_clr_eos_force();
 # ifdef GUI_MAY_SPAWN
 	if (!ends_excmd(*eap->arg))
@@ -5098,11 +5097,11 @@
 	fflush(stderr);
     else if (error_ga.ga_data != NULL)
     {
-	/* avoid putting up a message box with blanks only */
+	// avoid putting up a message box with blanks only
 	for (p = (char_u *)error_ga.ga_data; *p != NUL; ++p)
 	    if (!isspace(*p))
 	    {
-		/* Truncate a very long message, it will go off-screen. */
+		// Truncate a very long message, it will go off-screen.
 		if (STRLEN(p) > 2000)
 		    STRCPY(p + 2000 - 14, "...(truncated)");
 		(void)do_dialog(VIM_ERROR, (char_u *)_("Error"),
@@ -5150,7 +5149,7 @@
     update_topline();
     validate_cursor();
 
-    /* Trigger CursorMoved if the cursor moved. */
+    // Trigger CursorMoved if the cursor moved.
     if (!finish_op && (has_cursormoved()
 # ifdef FEAT_PROP_POPUP
 		|| popup_visible
@@ -5190,7 +5189,7 @@
 	need_cursor_line_redraw = FALSE;
     }
 # endif
-    update_screen(0);	/* may need to update the screen */
+    update_screen(0);	// may need to update the screen
     setcursor();
     out_flush_cursor(TRUE, FALSE);
 }
@@ -5205,8 +5204,8 @@
     char_u *
 get_find_dialog_text(
     char_u	*arg,
-    int		*wwordp,	/* return: TRUE if \< \> found */
-    int		*mcasep)	/* return: TRUE if \C found */
+    int		*wwordp,	// return: TRUE if \< \> found
+    int		*mcasep)	// return: TRUE if \C found
 {
     char_u	*text;
 
@@ -5222,14 +5221,14 @@
 	    int len = (int)STRLEN(text);
 	    int i;
 
-	    /* Remove "\V" */
+	    // Remove "\V"
 	    if (len >= 2 && STRNCMP(text, "\\V", 2) == 0)
 	    {
 		mch_memmove(text, text + 2, (size_t)(len - 1));
 		len -= 2;
 	    }
 
-	    /* Recognize "\c" and "\C" and remove. */
+	    // Recognize "\c" and "\C" and remove.
 	    if (len >= 2 && *text == '\\' && (text[1] == 'c' || text[1] == 'C'))
 	    {
 		*mcasep = (text[1] == 'C');
@@ -5237,7 +5236,7 @@
 		len -= 2;
 	    }
 
-	    /* Recognize "\<text\>" and remove. */
+	    // Recognize "\<text\>" and remove.
 	    if (len >= 4
 		    && STRNCMP(text, "\\<", 2) == 0
 		    && STRNCMP(text + len - 2, "\\>", 2) == 0)
@@ -5247,7 +5246,7 @@
 		text[len - 4] = NUL;
 	    }
 
-	    /* Recognize "\/" or "\?" and remove. */
+	    // Recognize "\/" or "\?" and remove.
 	    for (i = 0; i + 1 < len; ++i)
 		if (text[i] == '\\' && (text[i + 1] == '/'
 						       || text[i + 1] == '?'))
@@ -5266,10 +5265,10 @@
  */
     int
 gui_do_findrepl(
-    int		flags,		/* one of FRD_REPLACE, FRD_FINDNEXT, etc. */
+    int		flags,		// one of FRD_REPLACE, FRD_FINDNEXT, etc.
     char_u	*find_text,
     char_u	*repl_text,
-    int		down)		/* Search downwards. */
+    int		down)		// Search downwards.
 {
     garray_T	ga;
     int		i;
@@ -5279,13 +5278,13 @@
     int		save_did_emsg = did_emsg;
     static int  busy = FALSE;
 
-    /* When the screen is being updated we should not change buffers and
-     * windows structures, it may cause freed memory to be used.  Also don't
-     * do this recursively (pressing "Find" quickly several times. */
+    // When the screen is being updated we should not change buffers and
+    // windows structures, it may cause freed memory to be used.  Also don't
+    // do this recursively (pressing "Find" quickly several times.
     if (updating_screen || busy)
 	return FALSE;
 
-    /* refuse replace when text cannot be changed */
+    // refuse replace when text cannot be changed
     if ((type == FRD_REPLACE || type == FRD_REPLACEALL) && text_locked())
 	return FALSE;
 
@@ -5302,7 +5301,7 @@
 	ga_concat(&ga, (char_u *)"\\c");
     if (flags & FRD_WHOLE_WORD)
 	ga_concat(&ga, (char_u *)"\\<");
-    /* escape / and \ */
+    // escape slash and backslash
     p = vim_strsave_escaped(find_text, (char_u *)"/\\");
     if (p != NULL)
         ga_concat(&ga, p);
@@ -5313,7 +5312,7 @@
     if (type == FRD_REPLACEALL)
     {
 	ga_concat(&ga, (char_u *)"/");
-						/* escape / and \ */
+	// escape slash and backslash
 	p = vim_strsave_escaped(repl_text, (char_u *)"/\\");
 	if (p != NULL)
 	    ga_concat(&ga, p);
@@ -5324,8 +5323,8 @@
 
     if (type == FRD_REPLACE)
     {
-	/* Do the replacement when the text at the cursor matches.  Thus no
-	 * replacement is done if the cursor was moved! */
+	// Do the replacement when the text at the cursor matches.  Thus no
+	// replacement is done if the cursor was moved!
 	regmatch.regprog = vim_regcomp(ga.ga_data, RE_MAGIC + RE_STRING);
 	regmatch.rm_ic = 0;
 	if (regmatch.regprog != NULL)
@@ -5334,13 +5333,13 @@
 	    if (vim_regexec_nl(&regmatch, p, (colnr_T)0)
 						   && regmatch.startp[0] == p)
 	    {
-		/* Clear the command line to remove any old "No match"
-		 * error. */
+		// Clear the command line to remove any old "No match"
+		// error.
 		msg_end_prompt();
 
 		if (u_save_cursor() == OK)
 		{
-		    /* A button was pressed thus undo should be synced. */
+		    // A button was pressed thus undo should be synced.
 		    u_sync(FALSE);
 
 		    del_bytes((long)(regmatch.endp[0] - regmatch.startp[0]),
@@ -5356,7 +5355,7 @@
 
     if (type == FRD_REPLACEALL)
     {
-	/* A button was pressed, thus undo should be synced. */
+	// A button was pressed, thus undo should be synced.
 	u_sync(FALSE);
 	do_cmdline_cmd(ga.ga_data);
     }
@@ -5364,8 +5363,8 @@
     {
 	int searchflags = SEARCH_MSG + SEARCH_MARK;
 
-	/* Search for the next match.
-	 * Don't skip text under cursor for single replace. */
+	// Search for the next match.
+	// Don't skip text under cursor for single replace.
 	if (type == FRD_REPLACE)
 	    searchflags += SEARCH_START;
 	i = msg_scroll;
@@ -5375,26 +5374,26 @@
 	}
 	else
 	{
-	    /* We need to escape '?' if and only if we are searching in the up
-	     * direction */
+	    // We need to escape '?' if and only if we are searching in the up
+	    // direction
 	    p = vim_strsave_escaped(ga.ga_data, (char_u *)"?");
 	    if (p != NULL)
 	        (void)do_search(NULL, '?', p, 1L, searchflags, NULL);
 	    vim_free(p);
 	}
 
-	msg_scroll = i;	    /* don't let an error message set msg_scroll */
+	msg_scroll = i;	    // don't let an error message set msg_scroll
     }
 
-    /* Don't want to pass did_emsg to other code, it may cause disabling
-     * syntax HL if we were busy redrawing. */
+    // Don't want to pass did_emsg to other code, it may cause disabling
+    // syntax HL if we were busy redrawing.
     did_emsg = save_did_emsg;
 
     if (State & (NORMAL | INSERT))
     {
-	gui_update_screen();		/* update the screen */
-	msg_didout = 0;			/* overwrite any message */
-	need_wait_return = FALSE;	/* don't wait for return */
+	gui_update_screen();		// update the screen
+	msg_didout = 0;			// overwrite any message
+	need_wait_return = FALSE;	// don't wait for return
     }
 
     vim_free(ga.ga_data);
@@ -5432,9 +5431,9 @@
 {
     char_u	*p = cookie;
 
-    /* If Shift held down, change to first file's directory.  If the first
-     * item is a directory, change to that directory (and let the explorer
-     * plugin show the contents). */
+    // If Shift held down, change to first file's directory.  If the first
+    // item is a directory, change to that directory (and let the explorer
+    // plugin show the contents).
     if (p != NULL)
     {
 	if (mch_isdir(p))
@@ -5447,7 +5446,7 @@
 	vim_free(p);
     }
 
-    /* Update the screen display */
+    // Update the screen display
     update_screen(NOT_VALID);
 # ifdef FEAT_MENU
     gui_update_menus(0);
@@ -5500,9 +5499,9 @@
 		if (i > 0)
 		    add_to_input_buf((char_u*)" ", 1);
 
-		/* We don't know what command is used thus we can't be sure
-		 * about which characters need to be escaped.  Only escape the
-		 * most common ones. */
+		// We don't know what command is used thus we can't be sure
+		// about which characters need to be escaped.  Only escape the
+		// most common ones.
 # ifdef BACKSLASH_IN_FILENAME
 		p = vim_strsave_escaped(fnames[i], (char_u *)" \t\"|");
 # else
@@ -5518,20 +5517,20 @@
     }
     else
     {
-	/* Go to the window under mouse cursor, then shorten given "fnames" by
-	 * current window, because a window can have local current dir. */
+	// Go to the window under mouse cursor, then shorten given "fnames" by
+	// current window, because a window can have local current dir.
 	gui_wingoto_xy(x, y);
 	shorten_filenames(fnames, count);
 
-	/* If Shift held down, remember the first item. */
+	// If Shift held down, remember the first item.
 	if ((modifiers & MOUSE_SHIFT) != 0)
 	    p = vim_strsave(fnames[0]);
 	else
 	    p = NULL;
 
-	/* Handle the drop, :edit or :split to get to the file.  This also
-	 * frees fnames[].  Skip this if there is only one item, it's a
-	 * directory and Shift is held down. */
+	// Handle the drop, :edit or :split to get to the file.  This also
+	// frees fnames[].  Skip this if there is only one item, it's a
+	// directory and Shift is held down.
 	if (count == 1 && (modifiers & MOUSE_SHIFT) != 0
 						     && mch_isdir(fnames[0]))
 	{
diff --git a/src/gui_at_fs.c b/src/gui_at_fs.c
index c50816b..315723f 100644
--- a/src/gui_at_fs.c
+++ b/src/gui_at_fs.c
@@ -43,11 +43,11 @@
 
 #include "vim.h"
 
-/* Only include this when using the file browser */
+// Only include this when using the file browser
 
 #ifdef FEAT_BROWSE
 
-/* Weird complication: for "make lint" Text.h doesn't combine with Xm.h */
+// Weird complication: for "make lint" Text.h doesn't combine with Xm.h
 #if defined(FEAT_GUI_MOTIF) && defined(FMT8BIT)
 # undef FMT8BIT
 #endif
@@ -56,7 +56,7 @@
 # include "gui_at_sb.h"
 #endif
 
-/***************** SFinternal.h */
+////////////////// SFinternal.h
 
 #include <X11/Intrinsic.h>
 #include <X11/StringDefs.h>
@@ -170,7 +170,7 @@
 
 static int	SFstatus = SEL_FILE_NULL;
 
-/***************** forward declare static functions */
+///////////////// forward declare static functions
 
 static void SFsetText(char *path);
 static void SFtextChanged(void);
@@ -184,7 +184,7 @@
 static Boolean SFworkProc(void);
 static int SFcompareEntries(const void *p, const void *q);
 
-/***************** xstat.h */
+////////////////// xstat.h
 
 #ifndef S_IXUSR
 # define S_IXUSR 0100
@@ -198,7 +198,7 @@
 
 #define S_ISXXX(m) ((m) & (S_IXUSR | S_IXGRP | S_IXOTH))
 
-/***************** Path.c */
+////////////////// Path.c
 
 #include <pwd.h>
 
@@ -515,7 +515,7 @@
     SFhomeDir.path		= SFcurrentPath;
     SFhomeDir.entries		= entries;
     SFhomeDir.nEntries		= i;
-    SFhomeDir.vOrigin		= 0;	/* :-) */
+    SFhomeDir.vOrigin		= 0;	// :-)
     SFhomeDir.nChars		= maxChars + 2;
     SFhomeDir.hOrigin		= 0;
     SFhomeDir.changed		= 1;
@@ -969,7 +969,7 @@
 	    SFdirModTimer, (XtPointer) NULL);
 }
 
-/* Return a single character describing what kind of file STATBUF is.  */
+// Return a single character describing what kind of file STATBUF is.
 
     static char
 SFstatChar(stat_T *statBuf)
@@ -981,11 +981,11 @@
 #ifdef S_ISSOCK
     if (S_ISSOCK (statBuf->st_mode))
 	return '=';
-#endif /* S_ISSOCK */
+#endif // S_ISSOCK
     return ' ';
 }
 
-/***************** Draw.c */
+////////////////// Draw.c
 
 #ifdef FEAT_GUI_NEXTAW
 # include <X11/neXtaw/Cardinals.h>
@@ -1604,7 +1604,7 @@
 {
     int			nw;
 
-    /* sanity */
+    // sanity
     if (SFcurrentInvert[n] != -1)
     {
 	SFinvertEntry(n);
@@ -1980,7 +1980,7 @@
     return True;
 }
 
-/***************** Dir.c */
+////////////////// Dir.c
 
     static int
 SFcompareEntries(const void *p, const void *q)
@@ -2020,7 +2020,7 @@
 
     while ((dp = readdir(dirp)))
     {
-	/* Ignore "." and ".." */
+	// Ignore "." and ".."
 	if (strcmp(dp->d_name, ".") == 0 || strcmp(dp->d_name, "..") == 0)
 	    continue;
 	if (i >= Alloc)
@@ -2051,7 +2051,7 @@
     return 0;
 }
 
-/***************** SFinternal.h */
+////////////////// SFinternal.h
 
 #include <sys/param.h>
 #include <X11/cursorfont.h>
@@ -2202,7 +2202,7 @@
 	XSetForeground(gui.dpy, SFtextGC, fg);
 	XSetForeground(gui.dpy, SFlineGC, fg);
 
-	/* This is an xor GC, so combine the fg and background */
+	// This is an xor GC, so combine the fg and background
 	XSetBackground(gui.dpy, SFinvertGC, fg ^ bg);
 	XSetForeground(gui.dpy, SFinvertGC, fg ^ bg);
     }
@@ -2250,7 +2250,7 @@
 		XtNtitle, prompt,
 		NULL);
 
-    /* Add WM_DELETE_WINDOW protocol */
+    // Add WM_DELETE_WINDOW protocol
     XtAppAddActions(XtWidgetToApplicationContext(selFile),
 	    actions, XtNumber(actions));
     XtOverrideTranslations(selFile,
@@ -2522,7 +2522,7 @@
     XtSetMappedWhenManaged(selFile, False);
     XtRealizeWidget(selFile);
 
-    /* Add WM_DELETE_WINDOW protocol */
+    // Add WM_DELETE_WINDOW protocol
     SFwmDeleteWindow = XInternAtom(SFdisplay, "WM_DELETE_WINDOW", False);
     XSetWMProtocols(SFdisplay, XtWindow(selFile), &SFwmDeleteWindow, 1);
 
@@ -2609,7 +2609,7 @@
 	    XtNstring, &wcbuf,
 	NULL);
 	mbslength = wcstombs(NULL, wcbuf, 0);
-	/* Hack: some broken wcstombs() returns zero, just get a large buffer */
+	// Hack: some broken wcstombs() returns zero, just get a large buffer
 	if (mbslength == 0 && wcbuf != NULL && wcbuf[0] != 0)
 	    mbslength = MAXPATHL;
 	buf=(char *)XtMalloc(mbslength + 1);
@@ -2645,7 +2645,7 @@
     guicolor_T	fg,
     guicolor_T	bg,
     guicolor_T	scroll_fg,
-    guicolor_T	scroll_bg) /* The "Scrollbar" group colors */
+    guicolor_T	scroll_bg) // The "Scrollbar" group colors
 {
     static int	firstTime = 1;
     XEvent	event;
@@ -2731,4 +2731,4 @@
 	}
     }
 }
-#endif /* FEAT_BROWSE */
+#endif // FEAT_BROWSE
diff --git a/src/gui_at_sb.c b/src/gui_at_sb.c
index 72dc8c8..0a68210 100644
--- a/src/gui_at_sb.c
+++ b/src/gui_at_sb.c
@@ -56,9 +56,9 @@
 
 */
 
-/* ScrollBar.c */
-/* created by weissman, Mon Jul  7 13:20:03 1986 */
-/* converted by swick, Thu Aug 27 1987 */
+// ScrollBar.c
+// created by weissman, Mon Jul  7 13:20:03 1986
+// converted by swick, Thu Aug 27 1987
 
 #include "vim.h"
 
@@ -70,7 +70,7 @@
 
 #include <X11/Xmu/Drawing.h>
 
-/* Private definitions. */
+// Private definitions.
 
 static char defaultTranslations[] =
     "<Btn1Down>: NotifyScroll()\n\
@@ -164,7 +164,7 @@
 
 ScrollbarClassRec vim_scrollbarClassRec =
 {
-  { /* core fields */
+  { // core fields
     /* superclass	*/  (WidgetClass) &simpleClassRec,
     /* class_name	*/  "Scrollbar",
     /* size		*/  sizeof(ScrollbarRec),
@@ -198,13 +198,13 @@
     /* display_accelerator*/	XtInheritDisplayAccelerator,
     /* extension	*/  NULL
   },
-  { /* simple fields */
+  { // simple fields
     /* change_sensitive	*/  XtInheritChangeSensitive,
 #ifndef OLDXAW
     /* extension */	    NULL
 #endif
   },
-  { /* scrollbar fields */
+  { // scrollbar fields
     /* empty	    */	    0
   }
 };
@@ -240,7 +240,7 @@
     int			fill,
     int			draw_shadow)
 {
-    int tlen = bottom - top;	/* length of thumb in pixels */
+    int tlen = bottom - top;	// length of thumb in pixels
     int sw, margin, floor;
     int lx, ly, lw, lh;
 
@@ -273,24 +273,24 @@
     {
 	if (!(sbw->scrollbar.orientation == XtorientHorizontal))
 	{
-	    /* Top border */
+	    // Top border
 	    XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
 		    sbw->scrollbar.top_shadow_GC,
 		    lx, ly, lx + lw - 1, ly);
 
-	    /* Bottom border */
+	    // Bottom border
 	    XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
 		    sbw->scrollbar.bot_shadow_GC,
 		    lx, ly + lh - 1, lx + lw - 1, ly + lh - 1);
 	}
 	else
 	{
-	    /* Left border */
+	    // Left border
 	    XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
 		    sbw->scrollbar.top_shadow_GC,
 		    lx, ly, lx, ly + lh - 1);
 
-	    /* Right border */
+	    // Right border
 	    XDrawLine (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
 		    sbw->scrollbar.bot_shadow_GC,
 		    lx + lw - 1, ly, lx + lw - 1, ly + lh - 1);
@@ -306,24 +306,24 @@
 
 	if (!(sbw->scrollbar.orientation == XtorientHorizontal))
 	{
-	    /* Left border */
+	    // Left border
 	    XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
 		    sbw->scrollbar.top_shadow_GC,
 		    lx, ly, lx, ly + lh - 1);
 
-	    /* Right border */
+	    // Right border
 	    XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
 		    sbw->scrollbar.bot_shadow_GC,
 		    lx + lw - 1, ly, lx + lw - 1, ly + lh - 1);
 	}
 	else
 	{
-	    /* Top border */
+	    // Top border
 	    XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
 		    sbw->scrollbar.top_shadow_GC,
 		    lx, ly, lx + lw - 1, ly);
 
-	    /* Bottom border */
+	    // Bottom border
 	    XDrawLine(XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
 		    sbw->scrollbar.bot_shadow_GC,
 		    lx, ly + lh - 1, lx + lw - 1, ly + lh - 1);
@@ -336,11 +336,11 @@
     }
 }
 
-/* Paint the thumb in the area specified by sbw->top and
-   sbw->shown.	The old area is erased.  The painting and
-   erasing is done cleverly so that no flickering will occur.
+/*
+ * Paint the thumb in the area specified by sbw->top and
+ * sbw->shown.	The old area is erased.  The painting and
+ * erasing is done cleverly so that no flickering will occur.
  */
-
     static void
 PaintThumb(ScrollbarWidget sbw)
 {
@@ -369,7 +369,7 @@
 	if (newbot > oldbot)
 	    FillArea(sbw, AT_MAX(newtop, oldbot-1), newbot,  1,0);
 
-	/* Only draw the missing shadows */
+	// Only draw the missing shadows
 	FillArea(sbw, newtop, newbot, 0, 1);
     }
 }
@@ -408,7 +408,7 @@
 	point[5].x = thickness / 2;
 	point[5].y = sbw->scrollbar.length - sbw->scrollbar.shadow_width - 1;
 
-	/* horizontal arrows require that x and y coordinates be swapped */
+	// horizontal arrows require that x and y coordinates be swapped
 	if (sbw->scrollbar.orientation == XtorientHorizontal)
 	{
 	    int n;
@@ -420,7 +420,7 @@
 		point[n].y = swap;
 	    }
 	}
-	/* draw the up/left arrow */
+	// draw the up/left arrow
 	XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
 		sbw->scrollbar.gc,
 		point, 3,
@@ -433,7 +433,7 @@
 		sbw->scrollbar.top_shadow_GC,
 		point[0].x, point[0].y,
 		point[2].x, point[2].y);
-	/* draw the down/right arrow */
+	// draw the down/right arrow
 	XFillPolygon (XtDisplay ((Widget) sbw), XtWindow ((Widget) sbw),
 		sbw->scrollbar.gc,
 		point+3, 3,
@@ -497,8 +497,8 @@
 	gcValues.fill_style = FillSolid;
 	mask |= GCFillStyle;
     }
-    /* the creation should be non-caching, because */
-    /* we now set and clear clip masks on the gc returned */
+    // the creation should be non-caching, because
+    // we now set and clear clip masks on the gc returned
     sbw->scrollbar.gc = XtGetGC (w, mask, &gcValues);
 }
 
@@ -519,8 +519,8 @@
 
     static void
 Initialize(
-    Widget	request UNUSED,	/* what the client asked for */
-    Widget	new,		/* what we're going to give him */
+    Widget	request UNUSED,	// what the client asked for
+    Widget	new,		// what we're going to give him
     ArgList	args UNUSED,
     Cardinal	*num_args UNUSED)
 {
@@ -551,16 +551,16 @@
     Mask *valueMask,
     XSetWindowAttributes *attributes)
 {
-    /* The Simple widget actually stuffs the value in the valuemask. */
+    // The Simple widget actually stuffs the value in the valuemask.
     (*vim_scrollbarWidgetClass->core_class.superclass->core_class.realize)
 	(w, valueMask, attributes);
 }
 
     static Boolean
 SetValues(
-    Widget  current,	    /* what I am */
-    Widget  request UNUSED, /* what he wants me to be */
-    Widget  desired,	    /* what I will become */
+    Widget  current,	    // what I am
+    Widget  request UNUSED, // what he wants me to be
+    Widget  desired,	    // what I will become
     ArgList args UNUSED,
     Cardinal *num_args UNUSED)
 {
@@ -600,8 +600,8 @@
     static void
 Resize(Widget w)
 {
-    /* ForgetGravity has taken care of background, but thumb may
-     * have to move as a result of the new size. */
+    // ForgetGravity has taken care of background, but thumb may
+    // have to move as a result of the new size.
     SetDimensions ((ScrollbarWidget) w);
     Redisplay(w, (XEvent*) NULL, (Region)NULL);
 }
@@ -633,11 +633,11 @@
     if (region == NULL ||
 	    XRectInRegion (region, x, y, width, height) != RectangleOut)
     {
-	/* Forces entire thumb to be painted. */
+	// Forces entire thumb to be painted.
 	sbw->scrollbar.topLoc = -(sbw->scrollbar.length + 1);
 	PaintThumb (sbw);
     }
-    /* we'd like to be region aware here!!!! */
+    // we'd like to be region aware here!!!!
     PaintArrows(sbw);
 }
 
@@ -693,7 +693,7 @@
 {
     struct EventData *eventData = (struct EventData*)args;
 
-    return ((++eventData->count == QLength(dpy)) /* since PeekIf blocks */
+    return ((++eventData->count == QLength(dpy)) // since PeekIf blocks
 	|| CompareEvents(event, eventData->oldEvent));
 }
 
@@ -719,9 +719,9 @@
     static void
 ExtractPosition(
     XEvent	    *event,
-    Position	    *x,		/* RETURN */
-    Position	    *y,		/* RETURN */
-    unsigned int    *state)	/* RETURN */
+    Position	    *x,		// RETURN
+    Position	    *y,		// RETURN
+    unsigned int    *state)	// RETURN
 {
     switch (event->type)
     {
@@ -771,8 +771,8 @@
 
     ExtractPosition(event, &x, &y, (unsigned int *)NULL);
     loc = PICKLENGTH(sbw, x, y);
-    /* if the motion event puts the pointer in thumb, call Move and Notify */
-    /* also call Move and Notify if we're already in continuous scroll mode */
+    // if the motion event puts the pointer in thumb, call Move and Notify
+    // also call Move and Notify if we're already in continuous scroll mode
     if (sbw->scrollbar.scroll_mode == SMODE_CONT ||
 	    (loc >= sbw->scrollbar.topLoc &&
 	     loc <= sbw->scrollbar.topLoc + (int)sbw->scrollbar.shownLength))
@@ -876,7 +876,7 @@
 {
     ScrollbarWidget	sbw = (ScrollbarWidget) w;
 
-    if (sbw->scrollbar.scroll_mode == SMODE_CONT)   /* if scroll continuous */
+    if (sbw->scrollbar.scroll_mode == SMODE_CONT)   // if scroll continuous
 	return;
 
     if (LookAhead(w, event))
@@ -900,7 +900,7 @@
     int		    call_data = 0;
     unsigned int    state;
 
-    if (sbw->scrollbar.scroll_mode == SMODE_CONT)   /* if scroll continuous */
+    if (sbw->scrollbar.scroll_mode == SMODE_CONT)   // if scroll continuous
 	return;
 
     if (LookAhead (w, event))
@@ -968,7 +968,7 @@
     if (call_data)
 	XtCallCallbacks(w, XtNscrollProc, (XtPointer)(long_u)call_data);
 
-    /* establish autoscroll */
+    // establish autoscroll
     if (delay)
 	sbw->scrollbar.timer_id =
 	    XtAppAddTimeOut(XtWidgetToApplicationContext(w),
@@ -985,9 +985,9 @@
     ScrollbarWidget sbw = (ScrollbarWidget) w;
 
     sbw->scrollbar.scroll_mode = SMODE_NONE;
-    /* no need to remove any autoscroll timeout; it will no-op */
-    /* because the scroll_mode is SMODE_NONE */
-    /* but be sure to remove timeout in destroy proc */
+    // no need to remove any autoscroll timeout; it will no-op
+    // because the scroll_mode is SMODE_NONE
+    // but be sure to remove timeout in destroy proc
 }
 
     static float
@@ -1016,7 +1016,7 @@
     float		top;
     char		old_mode = sbw->scrollbar.scroll_mode;
 
-    sbw->scrollbar.scroll_mode = SMODE_CONT; /* indicate continuous scroll */
+    sbw->scrollbar.scroll_mode = SMODE_CONT; // indicate continuous scroll
 
     if (LookAhead(w, event))
 	return;
@@ -1028,7 +1028,7 @@
 
     top = FractionLoc(sbw, x, y);
 
-    if (old_mode != SMODE_CONT)		    /* start dragging: set offset */
+    if (old_mode != SMODE_CONT)		    // start dragging: set offset
     {
 	if (event->xbutton.button == Button2)
 	    sbw->scrollbar.scroll_off = sbw->scrollbar.shown / 2.;
@@ -1045,7 +1045,7 @@
 
     sbw->scrollbar.top = top;
     PaintThumb(sbw);
-    XFlush(XtDisplay(w));   /* re-draw it before Notifying */
+    XFlush(XtDisplay(w));   // re-draw it before Notifying
 }
 
 
@@ -1057,8 +1057,8 @@
     Cardinal	*num_params UNUSED)
 {
     ScrollbarWidget sbw = (ScrollbarWidget)w;
-    /* Use a union to avoid a warning for the weird conversion from float to
-     * XtPointer.  Comes from Xaw/Scrollbar.c. */
+    // Use a union to avoid a warning for the weird conversion from float to
+    // XtPointer.  Comes from Xaw/Scrollbar.c.
     union {
 	XtPointer xtp;
 	float xtf;
@@ -1067,9 +1067,9 @@
     if (LookAhead(w, event))
 	return;
 
-    /* thumbProc is not pretty, but is necessary for backwards
-       compatibility on those architectures for which it work{s,ed};
-       the intent is to pass a (truncated) float by value. */
+    // thumbProc is not pretty, but is necessary for backwards
+    // compatibility on those architectures for which it work{s,ed};
+    // the intent is to pass a (truncated) float by value.
     xtpf.xtf = sbw->scrollbar.top;
     XtCallCallbacks(w, XtNthumbProc, xtpf.xtp);
     XtCallCallbacks(w, XtNjumpProc, (XtPointer)&sbw->scrollbar.top);
@@ -1137,7 +1137,7 @@
 	    bot = sbw->scrollbar.top_shadow_GC;
 	}
 
-	/* top-left shadow */
+	// top-left shadow
 	if ((region == NULL) ||
 		(XRectInRegion (region, 0, 0, w, s) != RectangleOut) ||
 		(XRectInRegion (region, 0, 0, s, h) != RectangleOut))
@@ -1151,7 +1151,7 @@
 	    XFillPolygon (dpy, win, top, pt, 6, Complex, CoordModeOrigin);
 	}
 
-	/* bottom-right shadow */
+	// bottom-right shadow
 	if ((region == NULL) ||
 		(XRectInRegion (region, 0, hms, w, s) != RectangleOut) ||
 		(XRectInRegion (region, wms, 0, s, h) != RectangleOut))
@@ -1176,7 +1176,7 @@
 {
     ScrollbarWidget sbw = (ScrollbarWidget) w;
 
-    if (sbw->scrollbar.scroll_mode == SMODE_CONT) /* if still thumbing */
+    if (sbw->scrollbar.scroll_mode == SMODE_CONT) // if still thumbing
 	return;
 
     sbw->scrollbar.max = (max > 1.0) ? 1.0 :
diff --git a/src/gui_athena.c b/src/gui_athena.c
index 3620e65..99c7a67 100644
--- a/src/gui_athena.c
+++ b/src/gui_athena.c
@@ -34,7 +34,7 @@
 # include <X11/Xaw/Dialog.h>
 # include <X11/Xaw/Text.h>
 # include <X11/Xaw/AsciiText.h>
-#endif /* FEAT_GUI_NEXTAW */
+#endif // FEAT_GUI_NEXTAW
 
 #ifndef FEAT_GUI_NEXTAW
 # include "gui_at_sb.h"
@@ -46,9 +46,9 @@
 Widget textArea = (Widget)0;
 #ifdef FEAT_MENU
 static Widget menuBar = (Widget)0;
-static XtIntervalId timer = 0;	    /* 0 = expired, otherwise active */
+static XtIntervalId timer = 0;	    // 0 = expired, otherwise active
 
-/* Used to figure out menu ordering */
+// Used to figure out menu ordering
 static vimmenu_T *a_cur_menu = NULL;
 static Cardinal	athena_calculate_ins_pos(Widget);
 
@@ -96,7 +96,7 @@
 
     if (sb == NULL)
 	return;
-    else if (sb->wp != NULL)	    /* Left or right scrollbar */
+    else if (sb->wp != NULL)	    // Left or right scrollbar
     {
 	/*
 	 * Careful: need to get scrollbar info out of first (left) scrollbar
@@ -105,7 +105,7 @@
 	 */
 	sb_info = &sb->wp->w_scrollbars[0];
     }
-    else	    /* Bottom scrollbar */
+    else	    // Bottom scrollbar
 	sb_info = sb;
 
     value = (long)(*((float *)call_data) * (float)(sb_info->max + 1) + 0.001);
@@ -134,7 +134,7 @@
 
     if (sb == NULL)
 	return;
-    if (sb->wp != NULL)		/* Left or right scrollbar */
+    if (sb->wp != NULL)		// Left or right scrollbar
     {
 	/*
 	 * Careful: need to get scrollbar info out of first (left) scrollbar
@@ -144,7 +144,7 @@
 	sb_info = &sb->wp->w_scrollbars[0];
 
 	if (sb_info->size > 5)
-	    page = sb_info->size - 2;	    /* use two lines of context */
+	    page = sb_info->size - 2;	    // use two lines of context
 	else
 	    page = sb_info->size;
 #ifdef FEAT_GUI_NEXTAW
@@ -177,7 +177,7 @@
 	}
 #endif
     }
-    else			/* Bottom scrollbar */
+    else			// Bottom scrollbar
     {
 	sb_info = sb;
 #ifdef FEAT_GUI_NEXTAW
@@ -194,14 +194,14 @@
 		data = 1;
 	}
 #endif
-	if (data < -1)		/* page-width left */
+	if (data < -1)		// page-width left
 	{
 	    if (sb->size > 8)
 		data = -(sb->size - 5);
 	    else
 		data = -sb->size;
 	}
-	else if (data > 1)	/* page-width right */
+	else if (data > 1)	// page-width right
 	{
 	    if (sb->size > 8)
 		data = (sb->size - 5);
@@ -216,8 +216,8 @@
     else if (value < 0)
 	value = 0;
 
-    /* Update the bottom scrollbar an extra time (why is this needed?? */
-    if (sb->wp == NULL)		/* Bottom scrollbar */
+    // Update the bottom scrollbar an extra time (why is this needed??
+    if (sb->wp == NULL)		// Bottom scrollbar
 	gui_mch_set_scrollbar_thumb(sb, value, sb->size, sb->max);
 
     gui_drag_scrollbar(sb, value, FALSE);
@@ -235,7 +235,7 @@
      */
     gui.border_offset = gui.border_width;
 
-    /* The form containing all the other widgets */
+    // The form containing all the other widgets
     vimForm = XtVaCreateManagedWidget("vimForm",
 	formWidgetClass,	vimShell,
 	XtNborderWidth,		0,
@@ -243,7 +243,7 @@
     gui_athena_scroll_colors(vimForm);
 
 #ifdef FEAT_MENU
-    /* The top menu bar */
+    // The top menu bar
     menuBar = XtVaCreateManagedWidget("menuBar",
 	boxWidgetClass,		vimForm,
 	XtNresizable,		True,
@@ -259,8 +259,8 @@
 #endif
 
 #ifdef FEAT_TOOLBAR
-    /* Don't create it Managed, it will be managed when creating the first
-     * item.  Otherwise an empty toolbar shows up. */
+    // Don't create it Managed, it will be managed when creating the first
+    // item.  Otherwise an empty toolbar shows up.
     toolBar = XtVaCreateWidget("toolBar",
 	boxWidgetClass,		vimForm,
 	XtNresizable,		True,
@@ -276,7 +276,7 @@
     gui_athena_menu_colors(toolBar);
 #endif
 
-    /* The text area. */
+    // The text area.
     textArea = XtVaCreateManagedWidget("textArea",
 	coreWidgetClass,	vimForm,
 	XtNresizable,		True,
@@ -315,7 +315,7 @@
 		    XtNumber(pullAction));
 #endif
 
-    /* Pretend we don't have input focus, we will get an event if we do. */
+    // Pretend we don't have input focus, we will get an event if we do.
     gui.in_focus = FALSE;
 }
 
@@ -352,10 +352,9 @@
 	to.addr = (XtPointer)&font;
 	to.size = sizeof(XFontStruct *);
 #endif
-	/* Assumption: The menuBar children will use the same font as the
-	 *	       pulldown menu items AND they will all be of type
-	 *	       XtNfont.
-	 */
+	// Assumption: The menuBar children will use the same font as the
+	//	       pulldown menu items AND they will all be of type
+	//	       XtNfont.
 	XtVaGetValues(menuBar, XtNchildren, &children,
 			       XtNnumChildren, &num_children,
 			       NULL);
@@ -369,7 +368,7 @@
 #endif
 		    ) == False)
 	    return None;
-	/* "font" should now contain data */
+	// "font" should now contain data
     }
     else
 #ifdef FONTSET_ALWAYS
@@ -449,18 +448,18 @@
     static void
 get_toolbar_pixmap(vimmenu_T *menu, Pixmap *sen)
 {
-    char_u	buf[MAXPATHL];		/* buffer storing expanded pathname */
-    char	**xpm = NULL;		/* xpm array */
+    char_u	buf[MAXPATHL];		// buffer storing expanded pathname
+    char	**xpm = NULL;		// xpm array
 
-    buf[0] = NUL;			/* start with NULL path */
+    buf[0] = NUL;			// start with NULL path
 
     if (menu->iconfile != NULL)
     {
-	/* Use the "icon="  argument. */
+	// Use the "icon="  argument.
 	gui_find_iconfile(menu->iconfile, buf, "xpm");
 	createXpmImages(buf, NULL, sen);
 
-	/* If it failed, try using the menu name. */
+	// If it failed, try using the menu name.
 	if (*sen == (Pixmap)0 && gui_find_bitmap(menu->name, buf, "xpm") == OK)
 	    createXpmImages(buf, NULL, sen);
 	if (*sen != (Pixmap)0)
@@ -511,7 +510,7 @@
 	    &color[TOP_SHADOW].pixel,
 	    &color[HIGHLIGHT].pixel);
 
-    /* Setup the color substitution table */
+    // Setup the color substitution table
     attrs.valuemask = XpmColorSymbols;
     attrs.colorsymbols = color;
     attrs.numsymbols = 5;
@@ -519,7 +518,7 @@
     screenNum = DefaultScreen(gui.dpy);
     rootWindow = RootWindow(gui.dpy, screenNum);
 
-    /* Create the "sensitive" pixmap */
+    // Create the "sensitive" pixmap
     if (xpm != NULL)
 	status = XpmCreatePixmapFromData(gui.dpy, rootWindow, xpm,
 							 &map, &mask, &attrs);
@@ -532,13 +531,13 @@
 	GC	    back_gc;
 	GC	    mask_gc;
 
-	/* Need to create new Pixmaps with the mask applied. */
+	// Need to create new Pixmaps with the mask applied.
 	gcvalues.foreground = color[BACKGROUND].pixel;
 	back_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues);
 	mask_gc = XCreateGC(gui.dpy, map, GCForeground, &gcvalues);
 	XSetClipMask(gui.dpy, mask_gc, mask);
 
-	/* Create the "sensitive" pixmap. */
+	// Create the "sensitive" pixmap.
 	*sen = XCreatePixmap(gui.dpy, rootWindow,
 		 attrs.width, attrs.height,
 		 DefaultDepth(gui.dpy, screenNum));
@@ -567,7 +566,7 @@
     Dimension	border;
     int		height;
 
-    if (!XtIsManaged(toolBar))	/* nothing to do */
+    if (!XtIsManaged(toolBar))	// nothing to do
 	return;
     XtUnmanageChild(toolBar);
     XtVaGetValues(toolBar,
@@ -602,7 +601,7 @@
 		  NULL);
     XtManageChild(textArea);
 #ifdef FEAT_TOOLBAR
-    /* Give keyboard focus to the textArea instead of the toolbar. */
+    // Give keyboard focus to the textArea instead of the toolbar.
     gui_mch_reset_focus();
 #endif
 }
@@ -686,7 +685,7 @@
 
     XtUnmanageChild(menuBar);
     XtVaGetValues(menuBar, XtNborderWidth, &border, NULL);
-    /* avoid trouble when there are no menu items, and h is 1 */
+    // avoid trouble when there are no menu items, and h is 1
     height = h - 2 * border;
     if (height < 0)
 	height = 1;
@@ -709,19 +708,17 @@
     static Cardinal
 athena_calculate_ins_pos(Widget widget)
 {
-    /* Assume that if the parent of the vimmenu_T is NULL, then we can get
-     * to this menu by traversing "next", starting at "root_menu".
-     *
-     * This holds true for popup menus, toolbar, and toplevel menu items.
-     */
+    // Assume that if the parent of the vimmenu_T is NULL, then we can get
+    // to this menu by traversing "next", starting at "root_menu".
+    //
+    // This holds true for popup menus, toolbar, and toplevel menu items.
 
-    /* Popup menus:  "id" is NULL. Only submenu_id is valid */
+    // Popup menus:  "id" is NULL. Only submenu_id is valid
 
-    /* Menus that are not toplevel: "parent" will be non-NULL, "id" &
-     * "submenu_id" will be non-NULL.
-     */
+    // Menus that are not toplevel: "parent" will be non-NULL, "id" &
+    // "submenu_id" will be non-NULL.
 
-    /* Toplevel menus: "parent" is NULL, id is the widget of the menu item */
+    // Toplevel menus: "parent" is NULL, id is the widget of the menu item
 
     WidgetList	children;
     Cardinal	num_children = 0;
@@ -793,7 +790,7 @@
 	    gui_athena_menu_colors(menu->submenu_id);
 	    gui_athena_menu_font(menu->submenu_id);
 
-	    /* Don't update the menu height when it was set at a fixed value */
+	    // Don't update the menu height when it was set at a fixed value
 	    if (!gui.menu_height_fixed)
 	    {
 		/*
@@ -827,9 +824,8 @@
 
 	XtVaSetValues(menu->id, XtNrightBitmap, pullerBitmap,
 				NULL);
-	/* If there are other menu items that are not pulldown menus,
-	 * we need to adjust the right margins of those, too.
-	 */
+	// If there are other menu items that are not pulldown menus,
+	// we need to adjust the right margins of those, too.
 	{
 	    WidgetList	children;
 	    Cardinal	num_children;
@@ -865,11 +861,10 @@
     a_cur_menu = NULL;
 }
 
-/* Used to determine whether a SimpleMenu has pulldown entries.
- *
- * "id" is the parent of the menu items.
- * Ignore widget "ignore" in the pane.
- */
+// Used to determine whether a SimpleMenu has pulldown entries.
+//
+// "id" is the parent of the menu items.
+// Ignore widget "ignore" in the pane.
     static Boolean
 gui_athena_menu_has_submenus(Widget id, Widget ignore)
 {
@@ -900,8 +895,8 @@
 	{
 	    XtUnmanageChild(id);
 	    XtVaSetValues(id, XtNfontSet, gui.menu_fontset, NULL);
-	    /* We should force the widget to recalculate its
-	     * geometry now. */
+	    // We should force the widget to recalculate its
+	    // geometry now.
 	    XtManageChild(id);
 	}
 	else
@@ -929,7 +924,7 @@
 	if (has_submenu(id))
 	    XtVaSetValues(id, XtNrightBitmap, pullerBitmap, NULL);
 
-	/* Force the widget to recalculate its geometry now. */
+	// Force the widget to recalculate its geometry now.
 	if (managed)
 	    XtManageChild(id);
     }
@@ -953,10 +948,9 @@
     gui_mch_submenu_change(root_menu, FALSE);
 
     {
-	/* Iterate through the menubar menu items and get the height of
-	 * each one.  The menu bar height is set to the maximum of all
-	 * the heights.
-	 */
+	// Iterate through the menubar menu items and get the height of
+	// each one.  The menu bar height is set to the maximum of all
+	// the heights.
 	vimmenu_T *mp;
 	int max_height = 9999;
 
@@ -975,7 +969,7 @@
 	}
 	if (max_height != 9999)
 	{
-	    /* Don't update the menu height when it was set at a fixed value */
+	    // Don't update the menu height when it was set at a fixed value
 	    if (!gui.menu_height_fixed)
 	    {
 		Dimension   space, border;
@@ -988,12 +982,11 @@
 	    }
 	}
     }
-    /* Now, to simulate the window being resized.  Only, this
-     * will resize the window to its current state.
-     *
-     * There has to be a better way, but I do not see one at this time.
-     * (David Harrison)
-     */
+    // Now, to simulate the window being resized.  Only, this
+    // will resize the window to its current state.
+    //
+    // There has to be a better way, but I do not see one at this time.
+    // (David Harrison)
     {
 	Position w, h;
 
@@ -1048,7 +1041,7 @@
     static void
 gui_mch_submenu_change(
     vimmenu_T	*menu,
-    int		colors)		/* TRUE for colors, FALSE for font */
+    int		colors)		// TRUE for colors, FALSE for font
 {
     vimmenu_T	*mp;
 
@@ -1060,8 +1053,8 @@
 	    {
 		gui_athena_menu_colors(mp->id);
 #ifdef FEAT_TOOLBAR
-		/* For a toolbar item: Free the pixmap and allocate a new one,
-		 * so that the background color is right. */
+		// For a toolbar item: Free the pixmap and allocate a new one,
+		// so that the background color is right.
 		if (mp->image != (Pixmap)0)
 		{
 		    XFreePixmap(gui.dpy, mp->image);
@@ -1071,7 +1064,7 @@
 		}
 
 # ifdef FEAT_BEVAL_GUI
-		/* If we have a tooltip, then we need to change its colors */
+		// If we have a tooltip, then we need to change its colors
 		if (mp->tip != NULL)
 		{
 		    Arg args[2];
@@ -1089,9 +1082,8 @@
 	    {
 		gui_athena_menu_font(mp->id);
 #ifdef FEAT_BEVAL_GUI
-		/* If we have a tooltip, then we need to change its font */
-		/* Assume XtNinternational == True (in createBalloonEvalWindow)
-		 */
+		// If we have a tooltip, then we need to change its font
+		// Assume XtNinternational == True (in createBalloonEvalWindow)
 		if (mp->tip != NULL)
 		{
 		    Arg args[1];
@@ -1106,7 +1098,7 @@
 
 	if (mp->children != NULL)
 	{
-	    /* Set the colors/font for the tear off widget */
+	    // Set the colors/font for the tear off widget
 	    if (mp->submenu_id != (Widget)0)
 	    {
 		if (colors)
@@ -1114,7 +1106,7 @@
 		else
 		    gui_athena_menu_font(mp->submenu_id);
 	    }
-	    /* Set the colors for the children */
+	    // Set the colors for the children
 	    gui_mch_submenu_change(mp->children, colors);
 	}
     }
@@ -1171,18 +1163,15 @@
 	}
 	XtSetArg(args[n], XtNhighlightThickness, 0); n++;
 	type = commandWidgetClass;
-	/* TODO: figure out the position in the toolbar?
-	 *       This currently works fine for the default toolbar, but
-	 *       what if we add/remove items during later runtime?
-	 */
+	// TODO: figure out the position in the toolbar?
+	//       This currently works fine for the default toolbar, but
+	//       what if we add/remove items during later runtime?
 
-	/* NOTE: "idx" isn't used here.  The position is calculated by
-	 *       athena_calculate_ins_pos().  The position it calculates
-	 *       should be equal to "idx".
-	 */
-	/* TODO: Could we just store "idx" and use that as the child
-	 * placement?
-	 */
+	// NOTE: "idx" isn't used here.  The position is calculated by
+	//       athena_calculate_ins_pos().  The position it calculates
+	//       should be equal to "idx".
+	// TODO: Could we just store "idx" and use that as the child
+	// placement?
 
 	if (menu->id == NULL)
 	{
@@ -1206,10 +1195,10 @@
 	    gui_mch_show_toolbar(TRUE);
 	gui.toolbar_height = gui_mch_compute_toolbar_height();
 	return;
-    } /* toolbar menu item */
+    } // toolbar menu item
 # endif
 
-    /* Add menu separator */
+    // Add menu separator
     if (menu_is_separator(menu->name))
     {
 	menu->submenu_id = (Widget)0;
@@ -1235,10 +1224,9 @@
 	    if (menu->id == (Widget)0)
 		return;
 
-	    /* If there are other "pulldown" items in this pane, then adjust
-	     * the right margin to accommodate the arrow pixmap, otherwise
-	     * the right margin will be the same as the left margin.
-	     */
+	    // If there are other "pulldown" items in this pane, then adjust
+	    // the right margin to accommodate the arrow pixmap, otherwise
+	    // the right margin will be the same as the left margin.
 	    {
 		Dimension   left_margin;
 
@@ -1263,16 +1251,15 @@
     void
 gui_mch_show_toolbar(int showit)
 {
-    Cardinal	numChildren;	    /* how many children toolBar has */
+    Cardinal	numChildren;	    // how many children toolBar has
 
     if (toolBar == (Widget)0)
 	return;
     XtVaGetValues(toolBar, XtNnumChildren, &numChildren, NULL);
     if (showit && numChildren > 0)
     {
-	/* Assume that we want to show the toolbar if p_toolbar contains valid
-	 * option settings, therefore p_toolbar must not be NULL.
-	 */
+	// Assume that we want to show the toolbar if p_toolbar contains valid
+	// option settings, therefore p_toolbar must not be NULL.
 	WidgetList  children;
 
 	XtVaGetValues(toolBar, XtNchildren, &children, NULL);
@@ -1296,12 +1283,11 @@
 		for (toolbar = root_menu; toolbar; toolbar = toolbar->next)
 		    if (menu_is_toolbar(toolbar->dname))
 			break;
-		/* Assumption: toolbar is NULL if there is no toolbar,
-		 *	       otherwise it contains the toolbar menu structure.
-		 *
-		 * Assumption: "numChildren" == the number of items in the list
-		 *	       of items beginning with toolbar->children.
-		 */
+		// Assumption: toolbar is NULL if there is no toolbar,
+		//	       otherwise it contains the toolbar menu structure.
+		//
+		// Assumption: "numChildren" == the number of items in the list
+		//	       of items beginning with toolbar->children.
 		if (toolbar)
 		{
 		    for (cur = toolbar->children; cur; cur = cur->next)
@@ -1309,9 +1295,8 @@
 			Arg	    args[2];
 			int	    n = 0;
 
-			/* Enable/Disable tooltip (OK to enable while currently
-			 * enabled)
-			 */
+			// Enable/Disable tooltip (OK to enable while currently
+			// enabled)
 			if (cur->tip != NULL)
 			    (*action)(cur->tip);
 			if (text == 1)
@@ -1387,12 +1372,12 @@
     int
 gui_mch_compute_toolbar_height(void)
 {
-    Dimension	height;		    /* total Toolbar height */
-    Dimension	whgt;		    /* height of each widget */
-    Dimension	marginHeight;	    /* XmNmarginHeight of toolBar */
-    Dimension	shadowThickness;    /* thickness of Xtparent(toolBar) */
-    WidgetList	children;	    /* list of toolBar's children */
-    Cardinal	numChildren;	    /* how many children toolBar has */
+    Dimension	height;		    // total Toolbar height
+    Dimension	whgt;		    // height of each widget
+    Dimension	marginHeight;	    // XmNmarginHeight of toolBar
+    Dimension	shadowThickness;    // thickness of Xtparent(toolBar)
+    WidgetList	children;	    // list of toolBar's children
+    Cardinal	numChildren;	    // how many children toolBar has
     int		i;
 
     height = 0;
@@ -1438,7 +1423,7 @@
     void
 gui_mch_toggle_tearoffs(int enable UNUSED)
 {
-    /* no tearoff menus */
+    // no tearoff menus
 }
 
     void
@@ -1464,23 +1449,21 @@
 {
     Widget	parent;
 
-    /* There is no item for the toolbar. */
+    // There is no item for the toolbar.
     if (menu->id == (Widget)0)
 	return;
 
     parent = XtParent(menu->id);
 
-    /* When removing the last "pulldown" menu item from a pane, adjust the
-     * right margins of the remaining widgets.
-     */
+    // When removing the last "pulldown" menu item from a pane, adjust the
+    // right margins of the remaining widgets.
     if (menu->submenu_id != (Widget)0)
     {
-	/* Go through the menu items in the parent of this item and
-	 * adjust their margins, if necessary.
-	 * This takes care of the case when we delete the last menu item in a
-	 * pane that has a submenu.  In this case, there will be no arrow
-	 * pixmaps shown anymore.
-	 */
+	// Go through the menu items in the parent of this item and
+	// adjust their margins, if necessary.
+	// This takes care of the case when we delete the last menu item in a
+	// pane that has a submenu.  In this case, there will be no arrow
+	// pixmaps shown anymore.
 	{
 	    WidgetList  children;
 	    Cardinal    num_children;
@@ -1515,11 +1498,10 @@
 	    }
 	}
     }
-    /* Please be sure to destroy the parent widget first (i.e. menu->id).
-     *
-     * This code should be basically identical to that in the file gui_motif.c
-     * because they are both Xt based.
-     */
+    // Please be sure to destroy the parent widget first (i.e. menu->id).
+    //
+    // This code should be basically identical to that in the file gui_motif.c
+    // because they are both Xt based.
     if (menu->id != (Widget)0)
     {
 	Cardinal    num_children;
@@ -1535,15 +1517,14 @@
 #if defined(FEAT_TOOLBAR) && defined(FEAT_BEVAL_GUI)
 	if (parent == toolBar && menu->tip != NULL)
 	{
-	    /* We try to destroy this before the actual menu, because there are
-	     * callbacks, etc. that will be unregistered during the tooltip
-	     * destruction.
-	     *
-	     * If you call "gui_mch_destroy_beval_area()" after destroying
-	     * menu->id, then the tooltip's window will have already been
-	     * deallocated by Xt, and unknown behaviour will ensue (probably
-	     * a core dump).
-	     */
+	    // We try to destroy this before the actual menu, because there are
+	    // callbacks, etc. that will be unregistered during the tooltip
+	    // destruction.
+	    //
+	    // If you call "gui_mch_destroy_beval_area()" after destroying
+	    // menu->id, then the tooltip's window will have already been
+	    // deallocated by Xt, and unknown behaviour will ensue (probably
+	    // a core dump).
 	    gui_mch_destroy_beval_area(menu->tip);
 	    menu->tip = NULL;
 	}
@@ -1555,15 +1536,14 @@
 	 * will be deleted soon anyway, and it will delete its children like
 	 * all good widgets do.
 	 */
-	/* NOTE: The cause of the BadValue X Protocol Error is because when the
-	 * last child is destroyed, it is first unmanaged, thus causing a
-	 * geometry resize request from the parent Shell widget.
-	 * Since the Shell widget has no more children, it is resized to have
-	 * width/height of 0.  XConfigureWindow() is then called with the
-	 * width/height of 0, which generates the BadValue.
-	 *
-	 * This happens in phase two of the widget destruction process.
-	 */
+	// NOTE: The cause of the BadValue X Protocol Error is because when the
+	// last child is destroyed, it is first unmanaged, thus causing a
+	// geometry resize request from the parent Shell widget.
+	// Since the Shell widget has no more children, it is resized to have
+	// width/height of 0.  XConfigureWindow() is then called with the
+	// width/height of 0, which generates the BadValue.
+	//
+	// This happens in phase two of the widget destruction process.
 	{
 	    if (parent != menuBar
 #ifdef FEAT_TOOLBAR
@@ -1588,7 +1568,7 @@
 #ifdef FEAT_TOOLBAR
 	else if (parent == toolBar)
 	{
-	    /* When removing last toolbar item, don't display the toolbar. */
+	    // When removing last toolbar item, don't display the toolbar.
 	    XtVaGetValues(toolBar, XtNnumChildren, &num_children, NULL);
 	    if (num_children == 0)
 		gui_mch_show_toolbar(FALSE);
@@ -1620,7 +1600,7 @@
 	XtVaGetValues(w, XtNrightBitmap, &p, NULL);
 	if ((p != None) && (p != XtUnspecifiedPixmap))
 	{
-	    /* We are dealing with an item that has a submenu */
+	    // We are dealing with an item that has a submenu
 	    popup = get_popup_entry(XtParent(w));
 	    if (popup == (Widget)0)
 		return;
@@ -1629,7 +1609,8 @@
     }
 }
 
-/* This routine is used to calculate the position (in screen coordinates)
+/*
+ * This routine is used to calculate the position (in screen coordinates)
  * where a submenu should appear relative to the menu entry that popped it
  * up.  It should appear even with and just slightly to the left of the
  * rightmost end of the menu entry that caused the popup.
@@ -1642,12 +1623,12 @@
     XtPointer	client_data,
     XtPointer	call_data UNUSED)
 {
-    /* Assumption: XtIsSubclass(XtParent(w),simpleMenuWidgetClass) */
+    // Assumption: XtIsSubclass(XtParent(w),simpleMenuWidgetClass)
     vimmenu_T	*menu = (vimmenu_T *)client_data;
     Dimension	width;
     Position	root_x, root_y;
 
-    /* First, popdown any siblings that may have menus popped up */
+    // First, popdown any siblings that may have menus popped up
     {
 	vimmenu_T *i;
 
@@ -1660,8 +1641,8 @@
     XtVaGetValues(XtParent(w),
 		  XtNwidth,   &width,
 		  NULL);
-    /* Assumption: XawSimpleMenuGetActiveEntry(XtParent(w)) == menu->id */
-    /* i.e. This IS the active entry */
+    // Assumption: XawSimpleMenuGetActiveEntry(XtParent(w)) == menu->id
+    // i.e. This IS the active entry
     XtTranslateCoords(menu->id,width - 5, 0, &root_x, &root_y);
     XtVaSetValues(w, XtNx, root_x,
 		     XtNy, root_y,
@@ -1696,7 +1677,9 @@
     }
 }
 
-/* Used to determine if the given widget has a submenu that can be popped up. */
+/*
+ * Used to determine if the given widget has a submenu that can be popped up.
+ */
     static Boolean
 has_submenu(Widget widget)
 {
@@ -1740,7 +1723,7 @@
 	{
 	    if (timer)
 	    {
-		/* If the timeout hasn't been triggered, remove it */
+		// If the timeout hasn't been triggered, remove it
 		XtRemoveTimeOut(timer);
 	    }
 	    gui_athena_popdown_submenus_action(w,event,args,nargs);
@@ -1760,22 +1743,22 @@
 {
     Widget	menuw;
 
-    /* Get the active entry for the current menu */
+    // Get the active entry for the current menu
     if ((menuw = XawSimpleMenuGetActiveEntry(w)) == (Widget)0)
 	return NULL;
 
     return submenu_widget(menuw);
 }
 
-/* Given the widget that has been determined to have a submenu, return the submenu widget
- * that is to be popped up.
+/*
+ * Given the widget that has been determined to have a submenu, return the
+ * submenu widget that is to be popped up.
  */
     static Widget
 submenu_widget(Widget widget)
 {
-    /* Precondition: has_submenu(widget) == True
-     *	    XtIsSubclass(XtParent(widget),simpleMenuWidgetClass) == True
-     */
+    // Precondition: has_submenu(widget) == True
+    //	    XtIsSubclass(XtParent(widget),simpleMenuWidgetClass) == True
 
     char_u	*pullright_name;
     Widget	popup;
@@ -1785,8 +1768,8 @@
     vim_free(pullright_name);
 
     return popup;
-    /* Postcondition: (popup != NULL) implies
-     * (XtIsSubclass(popup,simpleMenuWidgetClass) == True) */
+    // Postcondition: (popup != NULL) implies
+    // (XtIsSubclass(popup,simpleMenuWidgetClass) == True)
 }
 
     void
@@ -1799,7 +1782,7 @@
     if (menu->submenu_id == (Widget)0)
 	return;
 
-    /* Position the popup menu at the pointer */
+    // Position the popup menu at the pointer
     if (XQueryPointer(gui.dpy, XtWindow(vimShell), &root, &child,
 		&rootx, &rooty, &winx, &winy, &mask))
     {
@@ -1819,7 +1802,7 @@
     XtPopupSpringLoaded(menu->submenu_id);
 }
 
-#endif /* FEAT_MENU */
+#endif // FEAT_MENU
 
 /*
  * Set the menu and scrollbar colors to their default values.
@@ -1866,7 +1849,7 @@
      */
     if (max == 0)
     {
-	/* So you can't scroll it at all (normally it scrolls past end) */
+	// So you can't scroll it at all (normally it scrolls past end)
 #ifdef FEAT_GUI_NEXTAW
 	XawScrollbarSetThumb(sb->id, 0.0, 1.0);
 #else
@@ -1921,7 +1904,7 @@
     void
 gui_mch_create_scrollbar(
     scrollbar_T *sb,
-    int		orient)	/* SBAR_VERT or SBAR_HORIZ */
+    int		orient)	// SBAR_VERT or SBAR_HORIZ
 {
     sb->id = XtVaCreateWidget("scrollBar",
 #ifdef FEAT_GUI_NEXTAW
@@ -1971,7 +1954,7 @@
 	    XtNbackground, gui.scroll_bg_pixel,
 	    NULL);
 
-    /* This is needed for the rectangle below the vertical scrollbars. */
+    // This is needed for the rectangle below the vertical scrollbars.
     if (sb == &gui.bottom_sbar && vimForm != (Widget)0)
 	gui_athena_scroll_colors(vimForm);
 }
@@ -1992,17 +1975,17 @@
  */
     char_u *
 gui_mch_browse(
-    int		saving UNUSED,	/* select file to write */
-    char_u	*title,		/* title for the window */
-    char_u	*dflt,		/* default name */
-    char_u	*ext UNUSED,	/* extension added */
-    char_u	*initdir,	/* initial directory, NULL for current dir */
-    char_u	*filter UNUSED)	/* file name filter */
+    int		saving UNUSED,	// select file to write
+    char_u	*title,		// title for the window
+    char_u	*dflt,		// default name
+    char_u	*ext UNUSED,	// extension added
+    char_u	*initdir,	// initial directory, NULL for current dir
+    char_u	*filter UNUSED)	// file name filter
 {
     Position x, y;
     char_u	dirbuf[MAXPATHL];
 
-    /* Concatenate "initdir" and "dflt". */
+    // Concatenate "initdir" and "dflt".
     if (initdir == NULL || *initdir == NUL)
 	mch_dirname(dirbuf, MAXPATHL);
     else if (STRLEN(initdir) + 2 < MAXPATHL)
@@ -2016,7 +1999,7 @@
 	STRCAT(dirbuf, dflt);
     }
 
-    /* Position the file selector just below the menubar */
+    // Position the file selector just below the menubar
     XtTranslateCoords(vimShell, (Position)0, (Position)
 #ifdef FEAT_MENU
 	    gui.menu_height
@@ -2111,13 +2094,13 @@
 	title = (char_u *)_("Vim dialog");
     dialogStatus = -1;
 
-    /* if our pointer is currently hidden, then we should show it. */
+    // if our pointer is currently hidden, then we should show it.
     gui_mch_mousehide(FALSE);
 
-    /* Check 'v' flag in 'guioptions': vertical button placement. */
+    // Check 'v' flag in 'guioptions': vertical button placement.
     vertical = (vim_strchr(p_go, GO_VERTICAL) != NULL);
 
-    /* The shell is created each time, to make sure it is resized properly */
+    // The shell is created each time, to make sure it is resized properly
     dialogshell = XtVaCreatePopupShell("dialogShell",
 	    transientShellWidgetClass, vimShell,
 	    XtNtitle, title,
@@ -2170,7 +2153,7 @@
 	XtSetKeyboardFocus(dialog, dialogtextfield);
     }
 
-    /* make a copy, so that we can insert NULs */
+    // make a copy, so that we can insert NULs
     buts = vim_strsave(buttons);
     if (buts == NULL)
 	return -1;
@@ -2213,7 +2196,7 @@
 
     XtRealizeWidget(dialogshell);
 
-    /* Setup for catching the close-window event, don't let it close Vim! */
+    // Setup for catching the close-window event, don't let it close Vim!
     dialogatom = XInternAtom(gui.dpy, "WM_DELETE_WINDOW", False);
     XSetWMProtocols(gui.dpy, XtWindow(dialogshell), &dialogatom, 1);
     XtAddEventHandler(dialogshell, NoEventMask, True, dialog_wm_handler, NULL);
@@ -2236,8 +2219,8 @@
 	y = 0;
     XtVaSetValues(dialogshell, XtNx, x, XtNy, y, NULL);
 
-    /* Position the mouse pointer in the dialog, required for when focus
-     * follows mouse. */
+    // Position the mouse pointer in the dialog, required for when focus
+    // follows mouse.
     XWarpPointer(gui.dpy, (Window)0, XtWindow(dialogshell), 0, 0, 0, 0, 20, 40);
 
 
diff --git a/src/gui_beval.c b/src/gui_beval.c
index 68d30e3..d3def17 100644
--- a/src/gui_beval.c
+++ b/src/gui_beval.c
@@ -12,7 +12,7 @@
 
 #if defined(FEAT_BEVAL_GUI) || defined(PROTO)
 
-/* on Win32 only get_beval_info() is required */
+// on Win32 only get_beval_info() is required
 #if !defined(FEAT_GUI_MSWIN) || defined(PROTO)
 
 #ifdef FEAT_GUI_GTK
@@ -32,7 +32,7 @@
 #  include <Xm/AtomMgr.h>
 #  include <Xm/Protocols.h>
 # else
-   /* Assume Athena */
+   // Assume Athena
 #  include <X11/Shell.h>
 #  ifdef FEAT_GUI_NEXTAW
 #   include <X11/neXtaw/Label.h>
@@ -95,7 +95,7 @@
     void	*clientData)
 {
 #ifndef FEAT_GUI_GTK
-    char	*display_name;	    /* get from gui.dpy */
+    char	*display_name;	    // get from gui.dpy
     int		screen_num;
     char	*p;
 #endif
@@ -157,7 +157,7 @@
 {
     cancelBalloon(beval);
     removeEventHandler(beval);
-    /* Children will automatically be destroyed */
+    // Children will automatically be destroyed
 # ifdef FEAT_GUI_GTK
     gtk_widget_destroy(beval->balloonShell);
 # else
@@ -198,7 +198,7 @@
     return current_beval;
 }
 #endif
-#endif /* !FEAT_GUI_MSWIN */
+#endif // !FEAT_GUI_MSWIN
 
 #if defined(FEAT_NETBEANS_INTG) || defined(FEAT_EVAL) || defined(PROTO)
 # if !defined(FEAT_GUI_MSWIN) || defined(PROTO)
@@ -216,8 +216,8 @@
     else
 	undrawBalloon(beval);
 }
-# endif /* !FEAT_GUI_MSWIN */
-#endif /* FEAT_NETBEANS_INTG || PROTO */
+# endif // !FEAT_GUI_MSWIN
+#endif // FEAT_NETBEANS_INTG || PROTO
 
 #if !defined(FEAT_GUI_MSWIN) || defined(PROTO)
 #if defined(FEAT_BEVAL_TIP) || defined(PROTO)
@@ -344,7 +344,7 @@
 	    break;
     }
 
-    return FALSE; /* continue emission */
+    return FALSE; // continue emission
 }
 
     static gint
@@ -364,7 +364,7 @@
 	    break;
     }
 
-    return FALSE; /* continue emission */
+    return FALSE; // continue emission
 }
 
     static void
@@ -383,7 +383,7 @@
 	beval->state = state;
 	cancelBalloon(beval);
 
-	/* Mouse buttons are pressed - no balloon now */
+	// Mouse buttons are pressed - no balloon now
 	if (!(state & ((int)GDK_BUTTON1_MASK | (int)GDK_BUTTON2_MASK
 						    | (int)GDK_BUTTON3_MASK)))
 	{
@@ -431,8 +431,8 @@
 						 ? (int)GDK_CONTROL_MASK : 0);
 		break;
 	    default:
-		/* Don't do this for key release, we apparently get these with
-		 * focus changes in some GTK version. */
+		// Don't do this for key release, we apparently get these with
+		// focus changes in some GTK version.
 		if (is_keypress)
 		    cancelBalloon(beval);
 		break;
@@ -455,7 +455,7 @@
      */
     requestBalloon(beval);
 
-    return FALSE; /* don't call me again */
+    return FALSE; // don't call me again
 }
 
 # if GTK_CHECK_VERSION(3,0,0)
@@ -499,11 +499,11 @@
 		       &event->area, widget, "tooltip",
 		       0, 0, -1, -1);
 
-    return FALSE; /* continue emission */
+    return FALSE; // continue emission
 }
-# endif /* !GTK_CHECK_VERSION(3,0,0) */
+# endif // !GTK_CHECK_VERSION(3,0,0)
 
-#else /* !FEAT_GUI_GTK */
+#else // !FEAT_GUI_GTK
 
     static void
 addEventHandler(Widget target, BalloonEval *beval)
@@ -551,8 +551,8 @@
     static void
 pointerEvent(BalloonEval *beval, XEvent *event)
 {
-    Position	distance;	    /* a measure of how much the pointer moved */
-    Position	delta;		    /* used to compute distance */
+    Position	distance;	    // a measure of how much the pointer moved
+    Position	delta;		    // used to compute distance
 
     switch (event->type)
     {
@@ -575,7 +575,7 @@
 		beval->state = event->xmotion.state;
 		if (beval->state & (Button1Mask|Button2Mask|Button3Mask))
 		{
-		    /* Mouse buttons are pressed - no balloon now */
+		    // Mouse buttons are pressed - no balloon now
 		    cancelBalloon(beval);
 		}
 		else if (beval->state & (Mod1Mask|Mod2Mask|Mod3Mask))
@@ -663,9 +663,9 @@
 	    break;
 
 	case LeaveNotify:
-		/* Ignore LeaveNotify events that are not "normal".
-		 * Apparently we also get it when somebody else grabs focus.
-		 * Happens for me every two seconds (some clipboard tool?) */
+		// Ignore LeaveNotify events that are not "normal".
+		// Apparently we also get it when somebody else grabs focus.
+		// Happens for me every two seconds (some clipboard tool?)
 		if (event->xcrossing.mode == NotifyNormal)
 		    cancelBalloon(beval);
 		break;
@@ -694,14 +694,14 @@
     requestBalloon(beval);
 }
 
-#endif /* !FEAT_GUI_GTK */
+#endif // !FEAT_GUI_GTK
 
     static void
 requestBalloon(BalloonEval *beval)
 {
     if (beval->showState != ShS_PENDING)
     {
-	/* Determine the beval to display */
+	// Determine the beval to display
 	if (beval->msgCB != NULL)
 	{
 	    beval->showState = ShS_PENDING;
@@ -733,7 +733,7 @@
     int		    uc;
     PangoAttrList   *attr_list;
 
-    /* Convert to UTF-8 if it isn't already */
+    // Convert to UTF-8 if it isn't already
     if (output_conv.vc_type != CONV_NONE)
     {
 	convbuf = string_convert(&output_conv, text, NULL);
@@ -741,14 +741,14 @@
 	    text = convbuf;
     }
 
-    /* First let's see how much we need to allocate */
+    // First let's see how much we need to allocate
     len = 0;
     for (p = text; *p != NUL; p += charlen)
     {
-	if ((*p & 0x80) == 0)	/* be quick for ASCII */
+	if ((*p & 0x80) == 0)	// be quick for ASCII
 	{
 	    charlen = 1;
-	    len += IS_NONPRINTABLE(*p) ? 2 : 1;	/* nonprintable: ^X */
+	    len += IS_NONPRINTABLE(*p) ? 2 : 1;	// nonprintable: ^X
 	}
 	else
 	{
@@ -756,14 +756,14 @@
 	    uc = utf_ptr2char(p);
 
 	    if (charlen != utf_char2len(uc))
-		charlen = 1; /* reject overlong sequences */
+		charlen = 1; // reject overlong sequences
 
-	    if (charlen == 1 || uc < 0xa0)	/* illegal byte or    */
-		len += 4;			/* control char: <xx> */
+	    if (charlen == 1 || uc < 0xa0)	// illegal byte or
+		len += 4;			// control char: <xx>
 	    else if (!utf_printable(uc))
-		/* Note: we assume here that utf_printable() doesn't
-		 * care about characters outside the BMP. */
-		len += 6;			/* nonprintable: <xxxx> */
+		// Note: we assume here that utf_printable() doesn't
+		// care about characters outside the BMP.
+		len += 6;			// nonprintable: <xxxx>
 	    else
 		len += charlen;
 	}
@@ -772,7 +772,7 @@
     attr_list = pango_attr_list_new();
     buf = alloc(len + 1);
 
-    /* Now go for the real work */
+    // Now go for the real work
     if (buf != NULL)
     {
 	attrentry_T	*aep;
@@ -787,7 +787,7 @@
 	GdkColor	color = { 0, 0, 0, 0 };
 #endif
 
-	/* Look up the RGB values of the SpecialKey foreground color. */
+	// Look up the RGB values of the SpecialKey foreground color.
 	aep = syn_gui_attr2entry(HL_ATTR(HLF_8));
 	pixel = (aep != NULL) ? aep->ae_u.gui.fg_color : INVALCOLOR;
 	if (pixel != INVALCOLOR)
@@ -807,7 +807,7 @@
 	p = text;
 	while (*p != NUL)
 	{
-	    /* Be quick for ASCII */
+	    // Be quick for ASCII
 	    if ((*p & 0x80) == 0 && !IS_NONPRINTABLE(*p))
 	    {
 		*pdest++ = *p++;
@@ -818,29 +818,29 @@
 		uc = utf_ptr2char(p);
 
 		if (charlen != utf_char2len(uc))
-		    charlen = 1; /* reject overlong sequences */
+		    charlen = 1; // reject overlong sequences
 
 		if (charlen == 1 || uc < 0xa0 || !utf_printable(uc))
 		{
 		    int	outlen;
 
-		    /* Careful: we can't just use transchar_byte() here,
-		     * since 'encoding' is not necessarily set to "utf-8". */
+		    // Careful: we can't just use transchar_byte() here,
+		    // since 'encoding' is not necessarily set to "utf-8".
 		    if (*p & 0x80 && charlen == 1)
 		    {
-			transchar_hex(pdest, *p);	/* <xx> */
+			transchar_hex(pdest, *p);	// <xx>
 			outlen = 4;
 		    }
 		    else if (uc >= 0x80)
 		    {
-			/* Note: we assume here that utf_printable() doesn't
-			 * care about characters outside the BMP. */
-			transchar_hex(pdest, uc);	/* <xx> or <xxxx> */
+			// Note: we assume here that utf_printable() doesn't
+			// care about characters outside the BMP.
+			transchar_hex(pdest, uc);	// <xx> or <xxxx>
 			outlen = (uc < 0x100) ? 4 : 6;
 		    }
 		    else
 		    {
-			transchar_nonprint(pdest, *p);	/* ^X */
+			transchar_nonprint(pdest, *p);	// ^X
 			outlen = 2;
 		    }
 		    if (pixel != INVALCOLOR)
@@ -940,36 +940,36 @@
 	pango_layout_set_wrap(layout, PANGO_WRAP_WORD);
 # endif
 	pango_layout_set_width(layout,
-		/* try to come up with some reasonable width */
+		// try to come up with some reasonable width
 		PANGO_SCALE * CLAMP(gui.num_cols * gui.char_width,
 				    screen_w / 2,
 				    MAX(20, screen_w - 20)));
 
-	/* Calculate the balloon's width and height. */
+	// Calculate the balloon's width and height.
 # if GTK_CHECK_VERSION(3,0,0)
 	gtk_widget_get_preferred_size(beval->balloonShell, &requisition, NULL);
 # else
 	gtk_widget_size_request(beval->balloonShell, &requisition);
 # endif
 
-	/* Compute position of the balloon area */
+	// Compute position of the balloon area
 	gdk_window_get_origin(gtk_widget_get_window(beval->target), &x, &y);
 	x += beval->x;
 	y += beval->y;
 
-	/* Get out of the way of the mouse pointer */
+	// Get out of the way of the mouse pointer
 	if (x + x_offset + requisition.width > screen_x + screen_w)
 	    y_offset += 15;
 	if (y + y_offset + requisition.height > screen_y + screen_h)
 	    y_offset = -requisition.height - EVAL_OFFSET_Y;
 
-	/* Sanitize values */
+	// Sanitize values
 	x = CLAMP(x + x_offset, 0,
 			    MAX(0, screen_x + screen_w - requisition.width));
 	y = CLAMP(y + y_offset, 0,
 			    MAX(0, screen_y + screen_h - requisition.height));
 
-	/* Show the balloon */
+	// Show the balloon
 # if GTK_CHECK_VERSION(3,0,0)
 	gtk_window_move(GTK_WINDOW(beval->balloonShell), x, y);
 # else
@@ -1048,7 +1048,7 @@
     gtk_container_add(GTK_CONTAINER(beval->balloonShell), beval->balloonLabel);
 }
 
-#else /* !FEAT_GUI_GTK */
+#else // !FEAT_GUI_GTK
 
 /*
  * Draw a balloon.
@@ -1063,15 +1063,15 @@
 
     if (beval->msg != NULL)
     {
-	/* Show the Balloon */
+	// Show the Balloon
 
-	/* Calculate the label's width and height */
+	// Calculate the label's width and height
 #ifdef FEAT_GUI_MOTIF
 	XmString s;
 
-	/* For the callback function we parse NL characters to create a
-	 * multi-line label.  This doesn't work for all languages, but
-	 * XmStringCreateLocalized() doesn't do multi-line labels... */
+	// For the callback function we parse NL characters to create a
+	// multi-line label.  This doesn't work for all languages, but
+	// XmStringCreateLocalized() doesn't do multi-line labels...
 	if (beval->msgCB != NULL)
 	    s = XmStringCreateLtoR((char *)beval->msg, XmFONTLIST_DEFAULT_TAG);
 	else
@@ -1092,8 +1092,8 @@
 	h += gui.border_offset << 1;
 	XtVaSetValues(beval->balloonLabel, XmNlabelString, s, NULL);
 	XmStringFree(s);
-#else /* Athena */
-	/* Assume XtNinternational == True */
+#else // Athena
+	// Assume XtNinternational == True
 	XFontSet	fset;
 	XFontSetExtents *ext;
 
@@ -1108,7 +1108,7 @@
 	XtVaSetValues(beval->balloonLabel, XtNlabel, beval->msg, NULL);
 #endif
 
-	/* Compute position of the balloon area */
+	// Compute position of the balloon area
 	tx = beval->x_root + EVAL_OFFSET_X;
 	ty = beval->y_root + EVAL_OFFSET_Y;
 	if ((tx + w) > beval->screen_width)
@@ -1121,13 +1121,13 @@
 		XmNy, ty,
 		NULL);
 #else
-	/* Athena */
+	// Athena
 	XtVaSetValues(beval->balloonShell,
 		XtNx, tx,
 		XtNy, ty,
 		NULL);
 #endif
-	/* Set tooltip colors */
+	// Set tooltip colors
 	{
 	    Arg args[2];
 
@@ -1136,7 +1136,7 @@
 	    args[0].value = gui.tooltip_bg_pixel;
 	    args[1].name = XmNforeground;
 	    args[1].value = gui.tooltip_fg_pixel;
-#else /* Athena */
+#else // Athena
 	    args[0].name = XtNbackground;
 	    args[0].value = gui.tooltip_bg_pixel;
 	    args[1].name = XtNforeground;
@@ -1194,7 +1194,7 @@
     beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval",
 		    overrideShellWidgetClass, gui.dpy, args, n);
 #else
-    /* Athena */
+    // Athena
     XtSetArg(args[n], XtNallowShellResize, True); n++;
     beval->balloonShell = XtAppCreateShell("balloonEval", "BalloonEval",
 		    overrideShellWidgetClass, gui.dpy, args, n);
@@ -1213,7 +1213,7 @@
 	beval->balloonLabel = XtCreateManagedWidget("balloonLabel",
 			xmLabelWidgetClass, beval->balloonShell, args, n);
     }
-#else /* FEAT_GUI_ATHENA */
+#else // FEAT_GUI_ATHENA
     XtSetArg(args[n], XtNforeground, gui.tooltip_fg_pixel); n++;
     XtSetArg(args[n], XtNbackground, gui.tooltip_bg_pixel); n++;
     XtSetArg(args[n], XtNinternational, True); n++;
@@ -1223,7 +1223,7 @@
 #endif
 }
 
-#endif /* !FEAT_GUI_GTK */
-#endif /* !FEAT_GUI_MSWIN */
+#endif // !FEAT_GUI_GTK
+#endif // !FEAT_GUI_MSWIN
 
-#endif /* FEAT_BEVAL_GUI */
+#endif // FEAT_BEVAL_GUI
diff --git a/src/gui_gtk.c b/src/gui_gtk.c
index a881aad..152f068 100644
--- a/src/gui_gtk.c
+++ b/src/gui_gtk.c
@@ -37,8 +37,8 @@
 # include "gui_gtk_f.h"
 #endif
 
-/* GTK defines MAX and MIN, but some system header files as well.  Undefine
- * them and don't use them. */
+// GTK defines MAX and MIN, but some system header files as well.  Undefine
+// them and don't use them.
 #ifdef MIN
 # undef MIN
 #endif
@@ -47,7 +47,7 @@
 #endif
 
 #ifdef FEAT_GUI_GNOME
-/* Gnome redefines _() and N_().  Grrr... */
+// Gnome redefines _() and N_().  Grrr...
 # ifdef _
 #  undef _
 # endif
@@ -64,7 +64,7 @@
 #  undef bind_textdomain_codeset
 # endif
 # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS)
-#  define ENABLE_NLS	/* so the texts in the dialog boxes are translated */
+#  define ENABLE_NLS	// so the texts in the dialog boxes are translated
 # endif
 # include <gnome.h>
 #endif
@@ -84,7 +84,7 @@
 
 # include <gtk/gtk.h>
 #else
-/* define these items to be able to generate prototypes without GTK */
+// define these items to be able to generate prototypes without GTK
 typedef int GtkWidget;
 # define gpointer int
 # define guint8 int
@@ -118,20 +118,20 @@
 # if GTK_CHECK_VERSION(3,10,0)
 static const char * const menu_themed_names[] =
 {
-    /* 00 */ "document-new",		/* sub. GTK_STOCK_NEW */
-    /* 01 */ "document-open",		/* sub. GTK_STOCK_OPEN */
-    /* 02 */ "document-save",		/* sub. GTK_STOCK_SAVE */
-    /* 03 */ "edit-undo",		/* sub. GTK_STOCK_UNDO */
-    /* 04 */ "edit-redo",		/* sub. GTK_STOCK_REDO */
-    /* 05 */ "edit-cut",		/* sub. GTK_STOCK_CUT */
-    /* 06 */ "edit-copy",		/* sub. GTK_STOCK_COPY */
-    /* 07 */ "edit-paste",		/* sub. GTK_STOCK_PASTE */
-    /* 08 */ "document-print",		/* sub. GTK_STOCK_PRINT */
-    /* 09 */ "help-browser",		/* sub. GTK_STOCK_HELP */
-    /* 10 */ "edit-find",		/* sub. GTK_STOCK_FIND */
+    /* 00 */ "document-new",		// sub. GTK_STOCK_NEW
+    /* 01 */ "document-open",		// sub. GTK_STOCK_OPEN
+    /* 02 */ "document-save",		// sub. GTK_STOCK_SAVE
+    /* 03 */ "edit-undo",		// sub. GTK_STOCK_UNDO
+    /* 04 */ "edit-redo",		// sub. GTK_STOCK_REDO
+    /* 05 */ "edit-cut",		// sub. GTK_STOCK_CUT
+    /* 06 */ "edit-copy",		// sub. GTK_STOCK_COPY
+    /* 07 */ "edit-paste",		// sub. GTK_STOCK_PASTE
+    /* 08 */ "document-print",		// sub. GTK_STOCK_PRINT
+    /* 09 */ "help-browser",		// sub. GTK_STOCK_HELP
+    /* 10 */ "edit-find",		// sub. GTK_STOCK_FIND
 #  if GTK_CHECK_VERSION(3,14,0)
-    /* Use the file names in gui_gtk_res.xml, cutting off the extension.
-     * Similar changes follow. */
+    // Use the file names in gui_gtk_res.xml, cutting off the extension.
+    // Similar changes follow.
     /* 11 */ "stock_vim_save_all",
     /* 12 */ "stock_vim_session_save",
     /* 13 */ "stock_vim_session_new",
@@ -142,9 +142,9 @@
     /* 13 */ "vim-session-new",
     /* 14 */ "vim-session-load",
 #  endif
-    /* 15 */ "system-run",		/* sub. GTK_STOCK_EXECUTE */
-    /* 16 */ "edit-find-replace",	/* sub. GTK_STOCK_FIND_AND_REPLACE */
-    /* 17 */ "window-close",		/* sub. GTK_STOCK_CLOSE, FIXME: fuzzy */
+    /* 15 */ "system-run",		// sub. GTK_STOCK_EXECUTE
+    /* 16 */ "edit-find-replace",	// sub. GTK_STOCK_FIND_AND_REPLACE
+    /* 17 */ "window-close",		// sub. GTK_STOCK_CLOSE, FIXME: fuzzy
 #  if GTK_CHECK_VERSION(3,14,0)
     /* 18 */ "stock_vim_window_maximize",
     /* 19 */ "stock_vim_window_minimize",
@@ -156,15 +156,15 @@
     /* 20 */ "vim-window-split",
     /* 21 */ "vim-shell",
 #  endif
-    /* 22 */ "go-previous",		/* sub. GTK_STOCK_GO_BACK */
-    /* 23 */ "go-next",			/* sub. GTK_STOCK_GO_FORWARD */
+    /* 22 */ "go-previous",		// sub. GTK_STOCK_GO_BACK
+    /* 23 */ "go-next",			// sub. GTK_STOCK_GO_FORWARD
 #  if GTK_CHECK_VERSION(3,14,0)
     /* 24 */ "stock_vim_find_help",
 #  else
     /* 24 */ "vim-find-help",
 #  endif
-    /* 25 */ "gtk-convert",		/* sub. GTK_STOCK_CONVERT */
-    /* 26 */ "go-jump",			/* sub. GTK_STOCK_JUMP_TO */
+    /* 25 */ "gtk-convert",		// sub. GTK_STOCK_CONVERT
+    /* 26 */ "go-jump",			// sub. GTK_STOCK_JUMP_TO
 #  if GTK_CHECK_VERSION(3,14,0)
     /* 27 */ "stock_vim_build_tags",
     /* 28 */ "stock_vim_window_split_vertical",
@@ -176,9 +176,9 @@
     /* 29 */ "vim-window-maximize-width",
     /* 30 */ "vim-window-minimize-width",
 #  endif
-    /* 31 */ "application-exit",	/* GTK_STOCK_QUIT */
+    /* 31 */ "application-exit",	// GTK_STOCK_QUIT
 };
-# else /* !GTK_CHECK_VERSION(3,10,0) */
+# else // !GTK_CHECK_VERSION(3,10,0)
 static const char * const menu_stock_ids[] =
 {
     /* 00 */ GTK_STOCK_NEW,
@@ -198,7 +198,7 @@
     /* 14 */ "vim-session-load",
     /* 15 */ GTK_STOCK_EXECUTE,
     /* 16 */ GTK_STOCK_FIND_AND_REPLACE,
-    /* 17 */ GTK_STOCK_CLOSE,		/* FIXME: fuzzy */
+    /* 17 */ GTK_STOCK_CLOSE,		// FIXME: fuzzy
     /* 18 */ "vim-window-maximize",
     /* 19 */ "vim-window-minimize",
     /* 20 */ "vim-window-split",
@@ -214,7 +214,7 @@
     /* 30 */ "vim-window-minimize-width",
     /* 31 */ GTK_STOCK_QUIT
 };
-# endif /* !GTK_CHECK_VERSION(3,10,0) */
+# endif // !GTK_CHECK_VERSION(3,10,0)
 
 # ifdef USE_GRESOURCE
 #  if !GTK_CHECK_VERSION(3,10,0)
@@ -240,7 +240,7 @@
     { NULL, NULL }
 };
 #  endif
-# endif /* USE_G_RESOURCE */
+# endif // USE_G_RESOURCE
 
 # ifndef USE_GRESOURCE
     static void
@@ -316,7 +316,7 @@
 	    pixel_size = 48;
 	    break;
 	case GTK_ICON_SIZE_INVALID:
-	    /* FALLTHROUGH */
+	    // FALLTHROUGH
 	default:
 	    pixel_size = 0;
 	    break;
@@ -337,7 +337,7 @@
 	image = gtk_image_new_from_icon_name("image-missing", icon_size);
 
     return image;
-# else /* !GTK_CHECK_VERSION(3,10,0) */
+# else // !GTK_CHECK_VERSION(3,10,0)
     GtkIconSet	    *icon_set;
     GtkIconSource   *icon_source;
 
@@ -358,7 +358,7 @@
     gtk_icon_set_unref(icon_set);
 
     return image;
-# endif /* !GTK_CHECK_VERSION(3,10,0) */
+# endif // !GTK_CHECK_VERSION(3,10,0)
 }
 
     static GtkWidget *
@@ -367,16 +367,16 @@
     GtkWidget	*image = NULL;
     char_u	buf[MAXPATHL];
 
-    /* First use a specified "icon=" argument. */
+    // First use a specified "icon=" argument.
     if (menu->iconfile != NULL && lookup_menu_iconfile(menu->iconfile, buf))
 	image = load_menu_iconfile(buf, icon_size);
 
-    /* If not found and not builtin specified try using the menu name. */
+    // If not found and not builtin specified try using the menu name.
     if (image == NULL && !menu->icon_builtin
 				     && lookup_menu_iconfile(menu->name, buf))
 	image = load_menu_iconfile(buf, icon_size);
 
-    /* Still not found?  Then use a builtin icon, a blank one as fallback. */
+    // Still not found?  Then use a builtin icon, a blank one as fallback.
     if (image == NULL)
     {
 # if GTK_CHECK_VERSION(3,10,0)
@@ -410,15 +410,15 @@
 			      GdkEventFocus *event UNUSED,
 			      gpointer data UNUSED)
 {
-    /* When we're in a GtkPlug, we don't have window focus events, only widget
-     * focus.  To emulate stand-alone gvim, if a button gets focus (e.g.,
-     * <Tab> into GtkPlug) immediately pass it to mainwin. */
+    // When we're in a GtkPlug, we don't have window focus events, only widget
+    // focus.  To emulate stand-alone gvim, if a button gets focus (e.g.,
+    // <Tab> into GtkPlug) immediately pass it to mainwin.
     if (gtk_socket_id != 0)
 	gtk_widget_grab_focus(gui.drawarea);
 
     return TRUE;
 }
-#endif /* FEAT_TOOLBAR */
+#endif // FEAT_TOOLBAR
 
 #if defined(FEAT_TOOLBAR) || defined(PROTO)
 
@@ -450,7 +450,7 @@
 
     gtk_icon_factory_add_default(factory);
     g_object_unref(factory);
-# else /* defined(USE_GRESOURCE) */
+# else // defined(USE_GRESOURCE)
     const char * const path_prefix = "/org/vim/gui/icon";
 #  if GTK_CHECK_VERSION(3,14,0)
     GdkScreen    *screen = NULL;
@@ -478,18 +478,18 @@
 				  gdk_pixbuf_get_height(pixbuf));
 	    if (size > 16)
 	    {
-		/* An icon theme is supposed to provide fixed-size
-		 * image files for each size, e.g., 16, 22, 24, ...
-		 * Naturally, in contrast to GtkIconSet, GtkIconTheme
-		 * won't prepare size variants for us out of a single
-		 * fixed-size image.
-		 *
-		 * Currently, Vim provides 24x24 images only while the
-		 * icon size on the menu and the toolbar is set to 16x16
-		 * by default.
-		 *
-		 * Resize them by ourselves until we have our own fully
-		 * fledged icon theme. */
+		// An icon theme is supposed to provide fixed-size
+		// image files for each size, e.g., 16, 22, 24, ...
+		// Naturally, in contrast to GtkIconSet, GtkIconTheme
+		// won't prepare size variants for us out of a single
+		// fixed-size image.
+		//
+		// Currently, Vim provides 24x24 images only while the
+		// icon size on the menu and the toolbar is set to 16x16
+		// by default.
+		//
+		// Resize them by ourselves until we have our own fully
+		// fledged icon theme.
 		GdkPixbuf *src = pixbuf;
 		pixbuf = gdk_pixbuf_scale_simple(src,
 						 16, 16,
@@ -503,7 +503,7 @@
 	    g_object_unref(pixbuf);
 	}
     }
-#  else /* !GTK_CHECK_VERSION(3,0.0) */
+#  else // !GTK_CHECK_VERSION(3,0.0)
     GtkIconFactory * const factory = gtk_icon_factory_new();
     IconNames *names;
 
@@ -525,11 +525,11 @@
 
     gtk_icon_factory_add_default(factory);
     g_object_unref(factory);
-#  endif /* !GTK_CHECK_VERSION(3,0,0) */
-# endif /* defined(USE_GRESOURCE) */
+#  endif // !GTK_CHECK_VERSION(3,0,0)
+# endif // defined(USE_GRESOURCE)
 }
 
-#endif /* FEAT_TOOLBAR */
+#endif // FEAT_TOOLBAR
 
 #if defined(FEAT_MENU) || defined(PROTO)
 
@@ -597,9 +597,9 @@
     char_u	*text;
     int		use_mnemonic;
 
-    /* It would be neat to have image menu items, but that would require major
-     * changes to Vim's menu system.  Not to mention that all the translations
-     * had to be updated. */
+    // It would be neat to have image menu items, but that would require major
+    // changes to Vim's menu system.  Not to mention that all the translations
+    // had to be updated.
     menu->id = gtk_menu_item_new();
 # if GTK_CHECK_VERSION(3,2,0)
     box = gtk_box_new(GTK_ORIENTATION_HORIZONTAL, 20);
@@ -653,7 +653,7 @@
     menu_item_new(menu, parent_widget);
 
 # if !GTK_CHECK_VERSION(3,4,0)
-    /* since the tearoff should always appear first, increment idx */
+    // since the tearoff should always appear first, increment idx
     if (parent != NULL && !menu_is_popup(parent->name))
 	++idx;
 # endif
@@ -722,8 +722,8 @@
 	    text    = CONVERT_TO_UTF8(menu->dname);
 	    tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]);
 	    if (tooltip != NULL && !utf_valid_string(tooltip, NULL))
-		/* Invalid text, can happen when 'encoding' is changed.  Avoid
-		 * a nasty GTK error message, skip the tooltip. */
+		// Invalid text, can happen when 'encoding' is changed.  Avoid
+		// a nasty GTK error message, skip the tooltip.
 		CONVERT_TO_UTF8_FREE(tooltip);
 
 #  if GTK_CHECK_VERSION(3,0,0)
@@ -764,22 +764,22 @@
 	}
     }
     else
-# endif /* FEAT_TOOLBAR */
+# endif // FEAT_TOOLBAR
     {
-	/* No parent, must be a non-menubar menu */
+	// No parent, must be a non-menubar menu
 	if (parent == NULL || parent->submenu_id == NULL)
 	    return;
 
 # if !GTK_CHECK_VERSION(3,4,0)
-	/* Make place for the possible tearoff handle item.  Not in the popup
-	 * menu, it doesn't have a tearoff item. */
+	// Make place for the possible tearoff handle item.  Not in the popup
+	// menu, it doesn't have a tearoff item.
 	if (!menu_is_popup(parent->name))
 	    ++idx;
 # endif
 
 	if (menu_is_separator(menu->name))
 	{
-	    /* Separator: Just add it */
+	    // Separator: Just add it
 # if GTK_CHECK_VERSION(3,0,0)
 	    menu->id = gtk_separator_menu_item_new();
 # else
@@ -793,7 +793,7 @@
 	    return;
 	}
 
-	/* Add textual menu item. */
+	// Add textual menu item.
 	menu_item_new(menu, parent->submenu_id);
 	gtk_widget_show(menu->id);
 	gtk_menu_shell_insert(GTK_MENU_SHELL(parent->submenu_id),
@@ -804,7 +804,7 @@
 			     G_CALLBACK(menu_item_activate), menu);
     }
 }
-#endif /* FEAT_MENU */
+#endif // FEAT_MENU
 
 
     void
@@ -859,7 +859,7 @@
     void
 gui_mch_toggle_tearoffs(int enable UNUSED)
 {
-    /* Do nothing */
+    // Do nothing
 }
 # else
     void
@@ -868,7 +868,7 @@
     recurse_tearoffs(root_menu, enable);
 }
 # endif
-#endif /* FEAT_MENU */
+#endif // FEAT_MENU
 
 #if defined(FEAT_TOOLBAR)
     static int
@@ -885,7 +885,7 @@
 
     return idx;
 }
-#endif /* FEAT_TOOLBAR */
+#endif // FEAT_TOOLBAR
 
 
 #if defined(FEAT_TOOLBAR) || defined(PROTO)
@@ -900,17 +900,17 @@
 	tooltip = CONVERT_TO_UTF8(menu->strings[MENU_INDEX_TIP]);
 	if (tooltip != NULL && utf_valid_string(tooltip, NULL))
 # if GTK_CHECK_VERSION(3,0,0)
-	    /* Only set the tooltip when it's valid utf-8. */
+	    // Only set the tooltip when it's valid utf-8.
 	    gtk_widget_set_tooltip_text(menu->id, (const gchar *)tooltip);
 # else
-	    /* Only set the tooltip when it's valid utf-8. */
+	    // Only set the tooltip when it's valid utf-8.
 	    gtk_tooltips_set_tip(GTK_TOOLBAR(gui.toolbar)->tooltips,
 				 menu->id, (const char *)tooltip, NULL);
 # endif
 	CONVERT_TO_UTF8_FREE(tooltip);
     }
 }
-#endif /* FEAT_TOOLBAR */
+#endif // FEAT_TOOLBAR
 
 
 #if defined(FEAT_MENU) || defined(PROTO)
@@ -920,13 +920,13 @@
     void
 gui_mch_destroy_menu(vimmenu_T *menu)
 {
-    /* Don't let gtk_container_remove automatically destroy menu->id. */
+    // Don't let gtk_container_remove automatically destroy menu->id.
     if (menu->id != NULL)
 	g_object_ref(menu->id);
 
-    /* Workaround for a spurious gtk warning in Ubuntu: "Trying to remove
-     * a child that doesn't believe we're its parent."
-     * Remove widget from gui.menubar before destroying it. */
+    // Workaround for a spurious gtk warning in Ubuntu: "Trying to remove
+    // a child that doesn't believe we're its parent."
+    // Remove widget from gui.menubar before destroying it.
     if (menu->id != NULL && gui.menubar != NULL
 			    && gtk_widget_get_parent(menu->id) == gui.menubar)
 	gtk_container_remove(GTK_CONTAINER(gui.menubar), menu->id);
@@ -953,7 +953,7 @@
 	    gtk_widget_destroy(menu->id);
     }
     else
-# endif /* FEAT_TOOLBAR */
+# endif // FEAT_TOOLBAR
     {
 	if (menu->submenu_id != NULL)
 	    gtk_widget_destroy(menu->submenu_id);
@@ -967,7 +967,7 @@
     menu->submenu_id = NULL;
     menu->id = NULL;
 }
-#endif /* FEAT_MENU */
+#endif // FEAT_MENU
 
 
 /*
@@ -1019,7 +1019,7 @@
     int		dragging = FALSE;
 
 #ifdef FEAT_XIM
-    /* cancel any preediting */
+    // cancel any preediting
     if (im_is_preediting())
 	xim_reset();
 #endif
@@ -1048,32 +1048,32 @@
 	    int			width;
 	    int			height;
 
-	    /* vertical scrollbar: need to set "dragging" properly in case
-	     * there are closed folds. */
+	    // vertical scrollbar: need to set "dragging" properly in case
+	    // there are closed folds.
 	    gdk_window_get_pointer(sb->id->window, &x, &y, &state);
 	    gdk_window_get_size(sb->id->window, &width, &height);
 	    if (x >= 0 && x < width && y >= 0 && y < height)
 	    {
 		if (y < width)
 		{
-		    /* up arrow: move one (closed fold) line up */
+		    // up arrow: move one (closed fold) line up
 		    dragging = FALSE;
 		    value = sb->wp->w_topline - 2;
 		}
 		else if (y > height - width)
 		{
-		    /* down arrow: move one (closed fold) line down */
+		    // down arrow: move one (closed fold) line down
 		    dragging = FALSE;
 		    value = sb->wp->w_topline;
 		}
 	    }
 	}
     }
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
     gui_drag_scrollbar(sb, value, dragging);
 }
 
-/* SBAR_VERT or SBAR_HORIZ */
+// SBAR_VERT or SBAR_HORIZ
     void
 gui_mch_create_scrollbar(scrollbar_T *sb, int orient)
 {
@@ -1191,25 +1191,25 @@
 
     title = CONVERT_TO_UTF8(title);
 
-    /* GTK has a bug, it only works with an absolute path. */
+    // GTK has a bug, it only works with an absolute path.
     if (initdir == NULL || *initdir == NUL)
 	mch_dirname(dirbuf, MAXPATHL);
     else if (vim_FullName(initdir, dirbuf, MAXPATHL - 2, FALSE) == FAIL)
 	dirbuf[0] = NUL;
-    /* Always need a trailing slash for a directory. */
+    // Always need a trailing slash for a directory.
     add_pathsep(dirbuf);
 
-    /* If our pointer is currently hidden, then we should show it. */
+    // If our pointer is currently hidden, then we should show it.
     gui_mch_mousehide(FALSE);
 
-    /* Hack: The GTK file dialog warns when it can't access a new file, this
-     * makes it shut up. http://bugzilla.gnome.org/show_bug.cgi?id=664587 */
+    // Hack: The GTK file dialog warns when it can't access a new file, this
+    // makes it shut up. http://bugzilla.gnome.org/show_bug.cgi?id=664587
     log_handler = g_log_set_handler(domain, G_LOG_LEVEL_WARNING,
 						  recent_func_log_func, NULL);
 
 #ifdef USE_FILE_CHOOSER
-    /* We create the dialog each time, so that the button text can be "Open"
-     * or "Save" according to the action. */
+    // We create the dialog each time, so that the button text can be "Open"
+    // or "Save" according to the action.
     fc = gtk_file_chooser_dialog_new((const gchar *)title,
 	    GTK_WINDOW(gui.mainwin),
 	    saving ? GTK_FILE_CHOOSER_ACTION_SAVE
@@ -1278,11 +1278,11 @@
     }
     gtk_widget_destroy(GTK_WIDGET(fc));
 
-#else /* !USE_FILE_CHOOSER */
+#else // !USE_FILE_CHOOSER
 
     if (gui.filedlg == NULL)
     {
-	GtkFileSelection	*fs;	/* shortcut */
+	GtkFileSelection	*fs;	// shortcut
 
 	gui.filedlg = gtk_file_selection_new((const gchar *)title);
 	gtk_window_set_modal(GTK_WINDOW(gui.filedlg), TRUE);
@@ -1296,7 +1296,7 @@
 		"clicked", GTK_SIGNAL_FUNC(browse_ok_cb), &gui);
 	gtk_signal_connect(GTK_OBJECT(fs->cancel_button),
 		"clicked", GTK_SIGNAL_FUNC(browse_cancel_cb), &gui);
-	/* gtk_signal_connect() doesn't work for destroy, it causes a hang */
+	// gtk_signal_connect() doesn't work for destroy, it causes a hang
 	gtk_signal_connect_object(GTK_OBJECT(gui.filedlg),
 		"destroy", GTK_SIGNAL_FUNC(browse_destroy_cb),
 		GTK_OBJECT(gui.filedlg));
@@ -1304,7 +1304,7 @@
     else
 	gtk_window_set_title(GTK_WINDOW(gui.filedlg), (const gchar *)title);
 
-    /* Concatenate "initdir" and "dflt". */
+    // Concatenate "initdir" and "dflt".
     if (dflt != NULL && *dflt != NUL
 			      && STRLEN(dirbuf) + 2 + STRLEN(dflt) < MAXPATHL)
 	STRCAT(dirbuf, dflt);
@@ -1314,14 +1314,14 @@
 
     gtk_widget_show(gui.filedlg);
     gtk_main();
-#endif /* !USE_FILE_CHOOSER */
+#endif // !USE_FILE_CHOOSER
     g_log_remove_handler(domain, log_handler);
 
     CONVERT_TO_UTF8_FREE(title);
     if (gui.browse_fname == NULL)
 	return NULL;
 
-    /* shorten the file name if possible */
+    // shorten the file name if possible
     return vim_strsave(shorten_fname1(gui.browse_fname));
 }
 
@@ -1337,10 +1337,10 @@
 	       char_u *title,
 	       char_u *initdir)
 {
-# if defined(GTK_FILE_CHOOSER)	    /* Only in GTK 2.4 and later. */
+# if defined(GTK_FILE_CHOOSER)	    // Only in GTK 2.4 and later.
     char_u		dirbuf[MAXPATHL];
     char_u		*p;
-    GtkWidget		*dirdlg;	    /* file selection dialog */
+    GtkWidget		*dirdlg;	    // file selection dialog
     char_u		*dirname = NULL;
 
     title = CONVERT_TO_UTF8(title);
@@ -1360,22 +1360,22 @@
 
     CONVERT_TO_UTF8_FREE(title);
 
-    /* if our pointer is currently hidden, then we should show it. */
+    // if our pointer is currently hidden, then we should show it.
     gui_mch_mousehide(FALSE);
 
-    /* GTK appears to insist on an absolute path. */
+    // GTK appears to insist on an absolute path.
     if (initdir == NULL || *initdir == NUL
 	       || vim_FullName(initdir, dirbuf, MAXPATHL - 10, FALSE) == FAIL)
 	mch_dirname(dirbuf, MAXPATHL - 10);
 
-    /* Always need a trailing slash for a directory.
-     * Also add a dummy file name, so that we get to the directory. */
+    // Always need a trailing slash for a directory.
+    // Also add a dummy file name, so that we get to the directory.
     add_pathsep(dirbuf);
     STRCAT(dirbuf, "@zd(*&1|");
     gtk_file_chooser_set_filename(GTK_FILE_CHOOSER(dirdlg),
 						      (const gchar *)dirbuf);
 
-    /* Run the dialog. */
+    // Run the dialog.
     if (gtk_dialog_run(GTK_DIALOG(dirdlg)) == GTK_RESPONSE_ACCEPT)
 	dirname = (char_u *)gtk_file_chooser_get_filename(
 						    GTK_FILE_CHOOSER(dirdlg));
@@ -1383,19 +1383,19 @@
     if (dirname == NULL)
 	return NULL;
 
-    /* shorten the file name if possible */
+    // shorten the file name if possible
     p = vim_strsave(shorten_fname1(dirname));
     g_free(dirname);
     return p;
 
-# else /* !defined(GTK_FILE_CHOOSER) */
-    /* For GTK 2.2 and earlier: fall back to ordinary file selector. */
+# else // !defined(GTK_FILE_CHOOSER)
+    // For GTK 2.2 and earlier: fall back to ordinary file selector.
     return gui_mch_browse(0, title, NULL, NULL, initdir, NULL);
-# endif /* !defined(GTK_FILE_CHOOSER) */
+# endif // !defined(GTK_FILE_CHOOSER)
 }
 
 
-#endif	/* FEAT_BROWSE */
+#endif	// FEAT_BROWSE
 
 #if defined(FEAT_GUI_DIALOG) || defined(PROTO)
 
@@ -1470,7 +1470,7 @@
 	    else
 		MB_PTR_ADV(p);
 	}
-	array[count] = NULL; /* currently not relied upon, but doesn't hurt */
+	array[count] = NULL; // currently not relied upon, but doesn't hurt
     }
 
     *n_buttons = count;
@@ -1546,22 +1546,22 @@
 dialog_add_buttons(GtkDialog *dialog, char_u *button_string)
 {
     char    **ok;
-    char    **ync;  /* "yes no cancel" */
+    char    **ync;  // "yes no cancel"
     char    **buttons;
     int	    n_buttons = 0;
     int	    idx;
 
-    button_string = vim_strsave(button_string); /* must be writable */
+    button_string = vim_strsave(button_string); // must be writable
     if (button_string == NULL)
 	return;
 
-    /* Check 'v' flag in 'guioptions': vertical button placement. */
+    // Check 'v' flag in 'guioptions': vertical button placement.
     if (vim_strchr(p_go, GO_VERTICAL) != NULL)
     {
 # if GTK_CHECK_VERSION(3,0,0)
-	/* Add GTK+ 3 code if necessary. */
-	/* N.B. GTK+ 3 doesn't allow you to access vbox and action_area via
-	 * the C API. */
+	// Add GTK+ 3 code if necessary.
+	// N.B. GTK+ 3 doesn't allow you to access vbox and action_area via
+	// the C API.
 # else
 	GtkWidget	*vbutton_box;
 
@@ -1569,7 +1569,7 @@
 	gtk_widget_show(vbutton_box);
 	gtk_box_pack_end(GTK_BOX(GTK_DIALOG(dialog)->vbox),
 						 vbutton_box, TRUE, FALSE, 0);
-	/* Overrule the "action_area" value, hopefully this works... */
+	// Overrule the "action_area" value, hopefully this works...
 	GTK_DIALOG(dialog)->action_area = vbutton_box;
 # endif
     }
@@ -1604,7 +1604,7 @@
 	 * since anyone can create their own dialogs using Vim functions.
 	 * Thus we have to check for those too.
 	 */
-	if (ok != NULL && ync != NULL) /* almost impossible to fail */
+	if (ok != NULL && ync != NULL) // almost impossible to fail
 	{
 # if GTK_CHECK_VERSION(3,10,0)
 	    if	    (button_equal(label, ok[0]))    label = _("OK");
@@ -1649,9 +1649,9 @@
  */
 typedef struct _DialogInfo
 {
-    int		ignore_enter;	    /* no default button, ignore "Enter" */
-    int		noalt;		    /* accept accelerators without Alt */
-    GtkDialog	*dialog;	    /* Widget of the dialog */
+    int		ignore_enter;	    // no default button, ignore "Enter"
+    int		noalt;		    // accept accelerators without Alt
+    GtkDialog	*dialog;	    // Widget of the dialog
 } DialogInfo;
 
     static gboolean
@@ -1659,14 +1659,14 @@
 {
     DialogInfo *di = (DialogInfo *)data;
 
-    /* Ignore hitting Enter (or Space) when there is no default button. */
+    // Ignore hitting Enter (or Space) when there is no default button.
     if (di->ignore_enter && (event->keyval == GDK_Return
 						     || event->keyval == ' '))
 	return TRUE;
-    else    /* A different key was pressed, return to normal behavior */
+    else    // A different key was pressed, return to normal behavior
 	di->ignore_enter = FALSE;
 
-    /* Close the dialog when hitting "Esc". */
+    // Close the dialog when hitting "Esc".
     if (event->keyval == GDK_Escape)
     {
 	gtk_dialog_response(di->dialog, GTK_RESPONSE_REJECT);
@@ -1681,16 +1681,16 @@
 		   gtk_window_get_mnemonic_modifier(GTK_WINDOW(widget)));
     }
 
-    return FALSE; /* continue emission */
+    return FALSE; // continue emission
 }
 
     int
-gui_mch_dialog(int	type,	    /* type of dialog */
-	       char_u	*title,	    /* title of dialog */
-	       char_u	*message,   /* message text */
-	       char_u	*buttons,   /* names of buttons */
-	       int	def_but,    /* default button */
-	       char_u	*textfield, /* text for textfield or NULL */
+gui_mch_dialog(int	type,	    // type of dialog
+	       char_u	*title,	    // title of dialog
+	       char_u	*message,   // message text
+	       char_u	*buttons,   // names of buttons
+	       int	def_but,    // default button
+	       char_u	*textfield, // text for textfield or NULL
 	       int	ex_cmd UNUSED)
 {
     GtkWidget	*dialog;
@@ -1710,7 +1710,7 @@
 	entry = gtk_entry_new();
 	gtk_widget_show(entry);
 
-	/* Make Enter work like pressing OK. */
+	// Make Enter work like pressing OK.
 	gtk_entry_set_activates_default(GTK_ENTRY(entry), TRUE);
 
 	text = CONVERT_TO_UTF8(textfield);
@@ -1748,8 +1748,8 @@
     else
 	dialoginfo.noalt = TRUE;
 
-    /* Allow activation of mnemonic accelerators without pressing <Alt> when
-     * there is no textfield.  Handle pressing Esc. */
+    // Allow activation of mnemonic accelerators without pressing <Alt> when
+    // there is no textfield.  Handle pressing Esc.
     g_signal_connect(G_OBJECT(dialog), "key-press-event",
 			 G_CALLBACK(&dialog_key_press_event_cb), &dialoginfo);
 
@@ -1759,18 +1759,18 @@
 	dialoginfo.ignore_enter = FALSE;
     }
     else
-	/* No default button, ignore pressing Enter. */
+	// No default button, ignore pressing Enter.
 	dialoginfo.ignore_enter = TRUE;
 
-    /* Show the mouse pointer if it's currently hidden. */
+    // Show the mouse pointer if it's currently hidden.
     gui_mch_mousehide(FALSE);
 
     response = gtk_dialog_run(GTK_DIALOG(dialog));
 
-    /* GTK_RESPONSE_NONE means the dialog was programmatically destroyed. */
+    // GTK_RESPONSE_NONE means the dialog was programmatically destroyed.
     if (response != GTK_RESPONSE_NONE)
     {
-	if (response == GTK_RESPONSE_ACCEPT)	    /* Enter pressed */
+	if (response == GTK_RESPONSE_ACCEPT)	    // Enter pressed
 	    response = def_but;
 	if (textfield != NULL)
 	{
@@ -1787,7 +1787,7 @@
     return response > 0 ? response : 0;
 }
 
-#endif /* FEAT_GUI_DIALOG */
+#endif // FEAT_GUI_DIALOG
 
 
 #if defined(FEAT_MENU) || defined(PROTO)
@@ -1828,16 +1828,16 @@
 			  "vim-has-im-menu", GINT_TO_POINTER(TRUE));
     }
 #  endif
-# endif /* FEAT_XIM */
+# endif // FEAT_XIM
 
 # if GTK_CHECK_VERSION(3,22,2)
     {
 	GdkEventButton trigger;
 
-	/* A pseudo event to have gtk_menu_popup_at_pointer() work. Since the
-	 * function calculates the popup menu position on the basis of the
-	 * actual pointer position when it is invoked, the fields x, y, x_root
-	 * and y_root are set to zero for convenience. */
+	// A pseudo event to have gtk_menu_popup_at_pointer() work. Since the
+	// function calculates the popup menu position on the basis of the
+	// actual pointer position when it is invoked, the fields x, y, x_root
+	// and y_root are set to zero for convenience.
 	trigger.type       = GDK_BUTTON_PRESS;
 	trigger.window     = gtk_widget_get_window(gui.drawarea);
 	trigger.send_event = FALSE;
@@ -1862,8 +1862,8 @@
 #endif
 }
 
-/* Ugly global variable to pass "mouse_pos" flag from gui_make_popup() to
- * popup_menu_position_func(). */
+// Ugly global variable to pass "mouse_pos" flag from gui_make_popup() to
+// popup_menu_position_func().
 static int popup_mouse_pos;
 
 /*
@@ -1892,7 +1892,7 @@
     else if (curwin != NULL && gui.drawarea != NULL &&
 	     gtk_widget_get_window(gui.drawarea) != NULL)
     {
-	/* Find the cursor position in the current window */
+	// Find the cursor position in the current window
 	*x += FILL_X(curwin->w_wincol + curwin->w_wcol + 1) + 1;
 	*y += FILL_Y(W_WINROW(curwin) + curwin->w_wrow + 1) + 1;
     }
@@ -1913,11 +1913,11 @@
 	GdkWindow * const win = gtk_widget_get_window(gui.drawarea);
 	GdkEventButton trigger;
 
-	/* A pseudo event to have gtk_menu_popup_at_*() functions work. Since
-	 * the position where the menu pops up is automatically adjusted by
-	 * the functions, none of the fields x, y, x_root and y_root has to be
-	 * set to a specific value here; therefore, they are set to zero for
-	 * convenience.*/
+	// A pseudo event to have gtk_menu_popup_at_*() functions work. Since
+	// the position where the menu pops up is automatically adjusted by
+	// the functions, none of the fields x, y, x_root and y_root has to be
+	// set to a specific value here; therefore, they are set to zero for
+	// convenience.
 	trigger.type       = GDK_BUTTON_PRESS;
 	trigger.window     = win;
 	trigger.send_event = FALSE;
@@ -1961,7 +1961,7 @@
     }
 }
 
-#endif /* FEAT_MENU */
+#endif // FEAT_MENU
 
 
 /*
@@ -1970,16 +1970,16 @@
 
 typedef struct _SharedFindReplace
 {
-    GtkWidget *dialog;	/* the main dialog widget */
-    GtkWidget *wword;	/* 'Whole word only' check button */
-    GtkWidget *mcase;	/* 'Match case' check button */
-    GtkWidget *up;	/* search direction 'Up' radio button */
-    GtkWidget *down;	/* search direction 'Down' radio button */
-    GtkWidget *what;	/* 'Find what' entry text widget */
-    GtkWidget *with;	/* 'Replace with' entry text widget */
-    GtkWidget *find;	/* 'Find Next' action button */
-    GtkWidget *replace;	/* 'Replace With' action button */
-    GtkWidget *all;	/* 'Replace All' action button */
+    GtkWidget *dialog;	// the main dialog widget
+    GtkWidget *wword;	// 'Whole word only' check button
+    GtkWidget *mcase;	// 'Match case' check button
+    GtkWidget *up;	// search direction 'Up' radio button
+    GtkWidget *down;	// search direction 'Down' radio button
+    GtkWidget *what;	// 'Find what' entry text widget
+    GtkWidget *with;	// 'Replace with' entry text widget
+    GtkWidget *find;	// 'Find Next' action button
+    GtkWidget *replace;	// 'Replace With' action button
+    GtkWidget *all;	// 'Replace All' action button
 } SharedFindReplace;
 
 static SharedFindReplace find_widgets = {NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL};
@@ -1991,13 +1991,12 @@
 		GdkEventKey	*event,
 		SharedFindReplace *frdp)
 {
-    /* If the user is holding one of the key modifiers we will just bail out,
-     * thus preserving the possibility of normal focus traversal.
-     */
+    // If the user is holding one of the key modifiers we will just bail out,
+    // thus preserving the possibility of normal focus traversal.
     if (event->state & (GDK_CONTROL_MASK | GDK_SHIFT_MASK))
 	return FALSE;
 
-    /* the Escape key synthesizes a cancellation action */
+    // the Escape key synthesizes a cancellation action
     if (event->keyval == GDK_Escape)
     {
 	gtk_widget_hide(frdp->dialog);
@@ -2005,9 +2004,8 @@
 	return TRUE;
     }
 
-    /* It would be delightful if it where possible to do search history
-     * operations on the K_UP and K_DOWN keys here.
-     */
+    // It would be delightful if it where possible to do search history
+    // operations on the K_UP and K_DOWN keys here.
 
     return FALSE;
 }
@@ -2093,23 +2091,21 @@
     g_return_val_if_fail(GTK_IS_ENTRY(entry) == TRUE, 0);
 
 #if GTK_CHECK_VERSION(2,18,0)
-    /* 2.18 introduced a new object GtkEntryBuffer to handle text data for
-     * GtkEntry instead of letting each instance of the latter have its own
-     * storage for that.  The code below is almost identical to the
-     * implementation of gtk_entry_get_text_length() for the versions >= 2.18.
-     */
+    // 2.18 introduced a new object GtkEntryBuffer to handle text data for
+    // GtkEntry instead of letting each instance of the latter have its own
+    // storage for that.  The code below is almost identical to the
+    // implementation of gtk_entry_get_text_length() for the versions >= 2.18.
     return gtk_entry_buffer_get_length(gtk_entry_get_buffer(entry));
 #elif GTK_CHECK_VERSION(2,14,0)
-    /* 2.14 introduced a new function to avoid memory management bugs which can
-     * happen when gtk_entry_get_text() is used without due care and attention.
-     */
+    // 2.14 introduced a new function to avoid memory management bugs which can
+    // happen when gtk_entry_get_text() is used without due care and attention.
     return gtk_entry_get_text_length(entry);
 #else
-    /* gtk_entry_get_text() returns the pointer to the storage allocated
-     * internally by the widget.  Accordingly, use the one with great care:
-     * Don't free it nor modify the contents it points to; call the function
-     * every time you need the pointer since its value may have been changed
-     * by the widget. */
+    // gtk_entry_get_text() returns the pointer to the storage allocated
+    // internally by the widget.  Accordingly, use the one with great care:
+    // Don't free it nor modify the contents it points to; call the function
+    // every time you need the pointer since its value may have been changed
+    // by the widget.
     return g_utf8_strlen(gtk_entry_get_text(entry), -1);
 #endif
 }
@@ -2117,7 +2113,7 @@
     static void
 find_replace_dialog_create(char_u *arg, int do_replace)
 {
-    GtkWidget	*hbox;		/* main top down box */
+    GtkWidget	*hbox;		// main top down box
     GtkWidget	*actionarea;
     GtkWidget	*table;
     GtkWidget	*tmp;
@@ -2132,7 +2128,7 @@
 
     frdp = (do_replace) ? (&repl_widgets) : (&find_widgets);
 
-    /* Get the search string to use. */
+    // Get the search string to use.
     entry_text = get_find_dialog_text(arg, &wword, &mcase);
 
     if (entry_text != NULL && output_conv.vc_type != CONV_NONE)
@@ -2157,9 +2153,9 @@
 	}
 	gtk_window_present(GTK_WINDOW(frdp->dialog));
 
-	/* For :promptfind dialog, always give keyboard focus to 'what' entry.
-	 * For :promptrepl dialog, give it to 'with' entry if 'what' has an
-	 * non-empty entry; otherwise, to 'what' entry. */
+	// For :promptfind dialog, always give keyboard focus to 'what' entry.
+	// For :promptrepl dialog, give it to 'with' entry if 'what' has an
+	// non-empty entry; otherwise, to 'what' entry.
 	gtk_widget_grab_focus(frdp->what);
 	if (do_replace && entry_get_text_length(GTK_ENTRY(frdp->what)) > 0)
 	    gtk_widget_grab_focus(frdp->with);
@@ -2170,7 +2166,7 @@
 
     frdp->dialog = gtk_dialog_new();
 #if GTK_CHECK_VERSION(3,0,0)
-    /* Nothing equivalent to gtk_dialog_set_has_separator() in GTK+ 3. */
+    // Nothing equivalent to gtk_dialog_set_has_separator() in GTK+ 3.
 #else
     gtk_dialog_set_has_separator(GTK_DIALOG(frdp->dialog), FALSE);
 #endif
@@ -2323,7 +2319,7 @@
 			 GINT_TO_POINTER(FRD_FINDNEXT));
     }
 
-    /* whole word only button */
+    // whole word only button
     frdp->wword = gtk_check_button_new_with_label(CONV(_("Match whole word only")));
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->wword),
 							(gboolean)wword);
@@ -2342,7 +2338,7 @@
 			 GTK_FILL, GTK_EXPAND, 2, 2);
 #endif
 
-    /* match case button */
+    // match case button
     frdp->mcase = gtk_check_button_new_with_label(CONV(_("Match case")));
     gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(frdp->mcase),
 							     (gboolean)mcase);
@@ -2385,7 +2381,7 @@
     gtk_container_set_border_width(GTK_CONTAINER(vbox), 0);
     gtk_container_add(GTK_CONTAINER(tmp), vbox);
 
-    /* 'Up' and 'Down' buttons */
+    // 'Up' and 'Down' buttons
     frdp->up = gtk_radio_button_new_with_label(NULL, CONV(_("Up")));
     gtk_box_pack_start(GTK_BOX(vbox), frdp->up, TRUE, TRUE, 0);
     frdp->down = gtk_radio_button_new_with_label(
@@ -2395,7 +2391,7 @@
     gtk_container_set_border_width(GTK_CONTAINER(vbox), 2);
     gtk_box_pack_start(GTK_BOX(vbox), frdp->down, TRUE, TRUE, 0);
 
-    /* vbox to hold the action buttons */
+    // vbox to hold the action buttons
 #if GTK_CHECK_VERSION(3,2,0)
     actionarea = gtk_button_box_new(GTK_ORIENTATION_VERTICAL);
 #else
@@ -2404,7 +2400,7 @@
     gtk_container_set_border_width(GTK_CONTAINER(actionarea), 2);
     gtk_box_pack_end(GTK_BOX(hbox), actionarea, FALSE, FALSE, 0);
 
-    /* 'Find Next' button */
+    // 'Find Next' button
 #if GTK_CHECK_VERSION(3,10,0)
     frdp->find = create_image_button(NULL, _("Find Next"));
 #else
@@ -2423,7 +2419,7 @@
 
     if (do_replace)
     {
-	/* 'Replace' button */
+	// 'Replace' button
 #if GTK_CHECK_VERSION(3,10,0)
 	frdp->replace = create_image_button(NULL, _("Replace"));
 #else
@@ -2436,7 +2432,7 @@
 			 G_CALLBACK(find_replace_cb),
 			 GINT_TO_POINTER(FRD_REPLACE));
 
-	/* 'Replace All' button */
+	// 'Replace All' button
 #if GTK_CHECK_VERSION(3,10,0)
 	frdp->all = create_image_button(NULL, _("Replace All"));
 #else
@@ -2450,7 +2446,7 @@
 			 GINT_TO_POINTER(FRD_REPLACEALL));
     }
 
-    /* 'Cancel' button */
+    // 'Cancel' button
 #if GTK_CHECK_VERSION(3,10,0)
     tmp = gtk_button_new_with_mnemonic(_("_Close"));
 #else
@@ -2472,7 +2468,7 @@
 #endif
     gtk_box_pack_end(GTK_BOX(hbox), tmp, FALSE, FALSE, 10);
 
-    /* Suppress automatic show of the unused action area */
+    // Suppress automatic show of the unused action area
 #if GTK_CHECK_VERSION(3,0,0)
 # if !GTK_CHECK_VERSION(3,12,0)
     gtk_widget_hide(gtk_dialog_get_action_area(GTK_DIALOG(frdp->dialog)));
@@ -2514,9 +2510,9 @@
     gboolean		direction_down;
     SharedFindReplace	*sfr;
 
-    flags = (int)(long)data;	    /* avoid a lint warning here */
+    flags = (int)(long)data;	    // avoid a lint warning here
 
-    /* Get the search/replace strings from the dialog */
+    // Get the search/replace strings from the dialog
     if (flags == FRD_FINDNEXT)
     {
 	repl_text = NULL;
@@ -2543,7 +2539,9 @@
     CONVERT_FROM_UTF8_FREE(find_text);
 }
 
-/* our usual callback function */
+/*
+ * our usual callback function
+ */
     static void
 entry_activate_cb(GtkWidget *widget UNUSED, gpointer data)
 {
@@ -2568,7 +2566,7 @@
     entry_text = gtk_entry_get_text(GTK_ENTRY(entry));
 
     if (!entry_text)
-	return;			/* shouldn't happen */
+	return;			// shouldn't happen
 
     nonempty = (entry_text[0] != '\0');
 
@@ -2589,8 +2587,8 @@
     void
 ex_helpfind(exarg_T *eap UNUSED)
 {
-    /* This will fail when menus are not loaded.  Well, it's only for
-     * backwards compatibility anyway. */
+    // This will fail when menus are not loaded.  Well, it's only for
+    // backwards compatibility anyway.
     do_cmdline_cmd((char_u *)"emenu ToolBar.FindHelp");
 }
 
@@ -2601,7 +2599,7 @@
 		     const gchar *message UNUSED,
 		     gpointer user_data UNUSED)
 {
-    /* We just want to suppress the warnings. */
-    /* http://bugzilla.gnome.org/show_bug.cgi?id=664587 */
+    // We just want to suppress the warnings.
+    // http://bugzilla.gnome.org/show_bug.cgi?id=664587
 }
 #endif
diff --git a/src/gui_gtk_f.c b/src/gui_gtk_f.c
index 1bff14b..ff9aee8 100644
--- a/src/gui_gtk_f.c
+++ b/src/gui_gtk_f.c
@@ -26,8 +26,8 @@
  */
 
 #include "vim.h"
-#include <gtk/gtk.h>	/* without this it compiles, but gives errors at
-			   runtime! */
+#include <gtk/gtk.h>	// without this it compiles, but gives errors at
+			// runtime!
 #include "gui_gtk_f.h"
 #if !GTK_CHECK_VERSION(3,0,0)
 # include <gtk/gtksignal.h>
@@ -44,8 +44,8 @@
 {
     GtkWidget *widget;
     GdkWindow *window;
-    gint x;		/* relative subwidget x position */
-    gint y;		/* relative subwidget y position */
+    gint x;		// relative subwidget x position
+    gint y;		// relative subwidget y position
     gint mapped;
 };
 
@@ -101,8 +101,7 @@
 static GtkWidgetClass *parent_class = NULL;
 #endif
 
-/* Public interface
- */
+// Public interface
 
     GtkWidget *
 gtk_form_new(void)
@@ -128,7 +127,7 @@
 
     g_return_if_fail(GTK_IS_FORM(form));
 
-    /* LINTED: avoid warning: conversion to 'unsigned long' */
+    // LINTED: avoid warning: conversion to 'unsigned long'
     child = g_new(GtkFormChild, 1);
     if (child == NULL)
 	return;
@@ -147,11 +146,10 @@
 
     form->children = g_list_append(form->children, child);
 
-    /* child->window must be created and attached to the widget _before_
-     * it has been realized, or else things will break with GTK2.  Note
-     * that gtk_widget_set_parent() realizes the widget if it's visible
-     * and its parent is mapped.
-     */
+    // child->window must be created and attached to the widget _before_
+    // it has been realized, or else things will break with GTK2.  Note
+    // that gtk_widget_set_parent() realizes the widget if it's visible
+    // and its parent is mapped.
     if (gtk_widget_get_realized(GTK_WIDGET(form)))
 	gtk_form_attach_child_window(form, child);
 
@@ -212,8 +210,7 @@
     }
 }
 
-/* Basic Object handling procedures
- */
+// Basic Object handling procedures
 #if GTK_CHECK_VERSION(3,0,0)
 G_DEFINE_TYPE(GtkForm, gtk_form, GTK_TYPE_CONTAINER)
 #else
@@ -237,7 +234,7 @@
     }
     return form_type;
 }
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
 
     static void
 gtk_form_class_init(GtkFormClass *klass)
@@ -364,14 +361,13 @@
 }
 
 
-/* After reading the documentation at
- * http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html
- * I think it should be possible to remove this function when compiling
- * against gtk-2.0.  It doesn't seem to cause problems, though.
- *
- * Well, I reckon at least the gdk_window_show(form->bin_window)
- * is necessary.  GtkForm is anything but a usual container widget.
- */
+// After reading the documentation at
+// http://developer.gnome.org/doc/API/2.0/gtk/gtk-changes-2-0.html
+// I think it should be possible to remove this function when compiling
+// against gtk-2.0.  It doesn't seem to cause problems, though.
+//
+// Well, I reckon at least the gdk_window_show(form->bin_window)
+// is necessary.  GtkForm is anything but a usual container widget.
     static void
 gtk_form_map(GtkWidget *widget)
 {
@@ -480,7 +476,7 @@
     *minimal_height = requisition.height;
     *natural_height = requisition.height;
 }
-#endif /* GTK_CHECK_VERSION(3,0,0) */
+#endif // GTK_CHECK_VERSION(3,0,0)
 
     static void
 gtk_form_size_allocate(GtkWidget *widget, GtkAllocation *allocation)
@@ -559,16 +555,16 @@
 	if (!gtk_widget_get_has_window(formchild->widget) &&
 		gtk_cairo_should_draw_window(cr, formchild->window))
 	{
-	    /* To get gtk_widget_draw() to work, it is required to call
-	     * gtk_widget_size_allocate() in advance with a well-posed
-	     * allocation for a given child widget in order to set a
-	     * certain private GtkWidget variable, called
-	     * widget->priv->alloc_need, to the proper value; otherwise,
-	     * gtk_widget_draw() fails and the relevant scrollbar won't
-	     * appear on the screen.
-	     *
-	     * Calling gtk_form_position_child() like this is one of ways
-	     * to make sure of that. */
+	    // To get gtk_widget_draw() to work, it is required to call
+	    // gtk_widget_size_allocate() in advance with a well-posed
+	    // allocation for a given child widget in order to set a
+	    // certain private GtkWidget variable, called
+	    // widget->priv->alloc_need, to the proper value; otherwise,
+	    // gtk_widget_draw() fails and the relevant scrollbar won't
+	    // appear on the screen.
+	    //
+	    // Calling gtk_form_position_child() like this is one of ways
+	    // to make sure of that.
 	    gtk_form_position_child(form, formchild, TRUE);
 
 	    gtk_form_render_background(formchild->widget, cr);
@@ -577,7 +573,7 @@
 
     return GTK_WIDGET_CLASS(gtk_form_parent_class)->draw(widget, cr);
 }
-#else /* !GTK_CHECK_VERSION(3,0,0) */
+#else // !GTK_CHECK_VERSION(3,0,0)
     static gint
 gtk_form_expose(GtkWidget *widget, GdkEventExpose *event)
 {
@@ -598,16 +594,15 @@
 
     return FALSE;
 }
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
 
-/* Container method
- */
+// Container method
     static void
 gtk_form_remove(GtkContainer *container, GtkWidget *widget)
 {
     GList *tmp_list;
     GtkForm *form;
-    GtkFormChild *child = NULL;	    /* init for gcc */
+    GtkFormChild *child = NULL;	    // init for gcc
 
     g_return_if_fail(GTK_IS_FORM(container));
 
@@ -634,9 +629,8 @@
 	    g_signal_handlers_disconnect_by_func(G_OBJECT(child->widget),
 		    FUNC2GENERIC(&gtk_form_child_unmap), child);
 
-	    /* FIXME: This will cause problems for reparenting NO_WINDOW
-	     * widgets out of a GtkForm
-	     */
+	    // FIXME: This will cause problems for reparenting NO_WINDOW
+	    // widgets out of a GtkForm
 	    gdk_window_set_user_data(child->window, NULL);
 	    gdk_window_destroy(child->window);
 	}
@@ -676,14 +670,13 @@
     }
 }
 
-/* Operations on children
- */
+// Operations on children
 
     static void
 gtk_form_attach_child_window(GtkForm *form, GtkFormChild *child)
 {
     if (child->window != NULL)
-	return; /* been there, done that */
+	return; // been there, done that
 
     if (!gtk_widget_get_has_window(child->widget))
     {
diff --git a/src/gui_gtk_x11.c b/src/gui_gtk_x11.c
index 9c41ffb..ef930a5 100644
--- a/src/gui_gtk_x11.c
+++ b/src/gui_gtk_x11.c
@@ -31,7 +31,7 @@
 #endif
 
 #ifdef FEAT_GUI_GNOME
-/* Gnome redefines _() and N_().  Grrr... */
+// Gnome redefines _() and N_().  Grrr...
 # ifdef _
 #  undef _
 # endif
@@ -48,16 +48,16 @@
 #  undef bind_textdomain_codeset
 # endif
 # if defined(FEAT_GETTEXT) && !defined(ENABLE_NLS)
-#  define ENABLE_NLS	/* so the texts in the dialog boxes are translated */
+#  define ENABLE_NLS	// so the texts in the dialog boxes are translated
 # endif
 # include <gnome.h>
 # include "version.h"
-/* missing prototype in bonobo-dock-item.h */
+// missing prototype in bonobo-dock-item.h
 extern void bonobo_dock_item_set_behavior(BonoboDockItem *dock_item, BonoboDockItemBehavior beh);
 #endif
 
 #if !defined(FEAT_GUI_GTK) && defined(PROTO)
-/* When generating prototypes we don't want syntax errors. */
+// When generating prototypes we don't want syntax errors.
 # define GdkAtom int
 # define GdkEventExpose int
 # define GdkEventFocus int
@@ -105,7 +105,7 @@
 #define GET_X_ATOM(atom)	gdk_x11_atom_to_xatom_for_display( \
 				    gtk_widget_get_display(gui.mainwin), atom)
 
-/* Selection type distinguishers */
+// Selection type distinguishers
 enum
 {
     TARGET_TYPE_NONE,
@@ -177,8 +177,8 @@
  */
 static GdkAtom html_atom = GDK_NONE;
 static GdkAtom utf8_string_atom = GDK_NONE;
-static GdkAtom vim_atom = GDK_NONE;	/* Vim's own special selection format */
-static GdkAtom vimenc_atom = GDK_NONE;	/* Vim's extended selection format */
+static GdkAtom vim_atom = GDK_NONE;	// Vim's own special selection format
+static GdkAtom vimenc_atom = GDK_NONE;	// Vim's extended selection format
 
 /*
  * Keycodes recognized by vim.
@@ -218,7 +218,7 @@
     {GDK_F19,		'F', '9'},
     {GDK_F20,		'F', 'A'},
     {GDK_F21,		'F', 'B'},
-    {GDK_Pause,		'F', 'B'}, /* Pause == F21 according to netbeans.txt */
+    {GDK_Pause,		'F', 'B'}, // Pause == F21 according to netbeans.txt
     {GDK_F22,		'F', 'C'},
     {GDK_F23,		'F', 'D'},
     {GDK_F24,		'F', 'E'},
@@ -249,7 +249,7 @@
     {GDK_Prior,		'k', 'P'},
     {GDK_Next,		'k', 'N'},
     {GDK_Print,		'%', '9'},
-    /* Keypad keys: */
+    // Keypad keys:
     {GDK_KP_Left,	'k', 'l'},
     {GDK_KP_Right,	'k', 'r'},
     {GDK_KP_Up,		'k', 'u'},
@@ -258,8 +258,8 @@
     {GDK_KP_Delete,	KS_EXTRA, (char_u)KE_KDEL},
     {GDK_KP_Home,	'K', '1'},
     {GDK_KP_End,	'K', '4'},
-    {GDK_KP_Prior,	'K', '3'},  /* page up */
-    {GDK_KP_Next,	'K', '5'},  /* page down */
+    {GDK_KP_Prior,	'K', '3'},  // page up
+    {GDK_KP_Next,	'K', '5'},  // page down
 
     {GDK_KP_Add,	'K', '6'},
     {GDK_KP_Subtract,	'K', '7'},
@@ -279,7 +279,7 @@
     {GDK_KP_8,		'K', 'K'},
     {GDK_KP_9,		'K', 'L'},
 
-    /* End of list marker: */
+    // End of list marker:
     {0, 0, 0}
 };
 
@@ -295,14 +295,14 @@
 #define ARG_ICONIC	7
 #define ARG_ROLE	8
 #define ARG_NETBEANS	9
-#define ARG_XRM		10	/* ignored */
-#define ARG_MENUFONT	11	/* ignored */
+#define ARG_XRM		10	// ignored
+#define ARG_MENUFONT	11	// ignored
 #define ARG_INDEX_MASK	0x00ff
-#define ARG_HAS_VALUE	0x0100	/* a value is expected after the argument */
-#define ARG_NEEDS_GUI	0x0200	/* need to initialize the GUI for this	  */
-#define ARG_FOR_GTK	0x0400	/* argument is handled by GTK+ or GNOME   */
-#define ARG_COMPAT_LONG	0x0800	/* accept -foo but substitute with --foo  */
-#define ARG_KEEP	0x1000	/* don't remove argument from argv[] */
+#define ARG_HAS_VALUE	0x0100	// a value is expected after the argument
+#define ARG_NEEDS_GUI	0x0200	// need to initialize the GUI for this
+#define ARG_FOR_GTK	0x0400	// argument is handled by GTK+ or GNOME
+#define ARG_COMPAT_LONG	0x0800	// accept -foo but substitute with --foo
+#define ARG_KEEP	0x1000	// don't remove argument from argv[]
 
 /*
  * This table holds all the X GUI command line options allowed.  This includes
@@ -320,7 +320,7 @@
 
 static const cmdline_option_T cmdline_options[] =
 {
-    /* We handle these options ourselves */
+    // We handle these options ourselves
     {"-fn",		ARG_FONT|ARG_HAS_VALUE},
     {"-font",		ARG_FONT|ARG_HAS_VALUE},
     {"-geom",		ARG_GEOMETRY|ARG_HAS_VALUE},
@@ -336,12 +336,12 @@
     {"-iconic",		ARG_ICONIC},
     {"--role",		ARG_ROLE|ARG_HAS_VALUE},
 #ifdef FEAT_NETBEANS_INTG
-    {"-nb",		ARG_NETBEANS},	      /* non-standard value format */
-    {"-xrm",		ARG_XRM|ARG_HAS_VALUE},		/* not implemented */
-    {"-mf",		ARG_MENUFONT|ARG_HAS_VALUE},	/* not implemented */
-    {"-menufont",	ARG_MENUFONT|ARG_HAS_VALUE},	/* not implemented */
+    {"-nb",		ARG_NETBEANS},	      // non-standard value format
+    {"-xrm",		ARG_XRM|ARG_HAS_VALUE},		// not implemented
+    {"-mf",		ARG_MENUFONT|ARG_HAS_VALUE},	// not implemented
+    {"-menufont",	ARG_MENUFONT|ARG_HAS_VALUE},	// not implemented
 #endif
-    /* Arguments handled by GTK (and GNOME) internally. */
+    // Arguments handled by GTK (and GNOME) internally.
     {"--g-fatal-warnings",	ARG_FOR_GTK},
     {"--gdk-debug",		ARG_FOR_GTK|ARG_HAS_VALUE},
     {"--gdk-no-debug",		ARG_FOR_GTK|ARG_HAS_VALUE},
@@ -369,7 +369,7 @@
     {"-?",			ARG_FOR_GTK|ARG_NEEDS_GUI},
     {"--help",			ARG_FOR_GTK|ARG_NEEDS_GUI|ARG_KEEP},
     {"--usage",			ARG_FOR_GTK|ARG_NEEDS_GUI},
-# if 0 /* conflicts with Vim's own --version argument */
+# if 0 // conflicts with Vim's own --version argument
     {"--version",		ARG_FOR_GTK|ARG_NEEDS_GUI},
 # endif
     {"--disable-crash-dialog",	ARG_FOR_GTK},
@@ -441,14 +441,14 @@
 
     while (i < *argc)
     {
-	/* Don't waste CPU cycles on non-option arguments. */
+	// Don't waste CPU cycles on non-option arguments.
 	if (argv[i][0] != '-' && argv[i][0] != '+')
 	{
 	    ++i;
 	    continue;
 	}
 
-	/* Look for argv[i] in cmdline_options[] table. */
+	// Look for argv[i] in cmdline_options[] table.
 	for (option = &cmdline_options[0]; option->name != NULL; ++option)
 	{
 	    len = strlen(option->name);
@@ -457,11 +457,11 @@
 	    {
 		if (argv[i][len] == '\0')
 		    break;
-		/* allow --foo=bar style */
+		// allow --foo=bar style
 		if (argv[i][len] == '=' && (option->flags & ARG_HAS_VALUE))
 		    break;
 #ifdef FEAT_NETBEANS_INTG
-		/* darn, -nb has non-standard syntax */
+		// darn, -nb has non-standard syntax
 		if (vim_strchr((char_u *)":=", argv[i][len]) != NULL
 			&& (option->flags & ARG_INDEX_MASK) == ARG_NETBEANS)
 		    break;
@@ -470,13 +470,13 @@
 	    else if ((option->flags & ARG_COMPAT_LONG)
 			&& strcmp(argv[i], option->name + 1) == 0)
 	    {
-		/* Replace the standard X arguments "-name" and "-display"
-		 * with their GNU-style long option counterparts. */
+		// Replace the standard X arguments "-name" and "-display"
+		// with their GNU-style long option counterparts.
 		argv[i] = (char *)option->name;
 		break;
 	    }
 	}
-	if (option->name == NULL) /* no match */
+	if (option->name == NULL) // no match
 	{
 	    ++i;
 	    continue;
@@ -484,16 +484,16 @@
 
 	if (option->flags & ARG_FOR_GTK)
 	{
-	    /* Move the argument into gui_argv, which
-	     * will later be passed to gtk_init_check() */
+	    // Move the argument into gui_argv, which
+	    // will later be passed to gtk_init_check()
 	    gui_argv[gui_argc++] = argv[i];
 	}
 	else
 	{
 	    char *value = NULL;
 
-	    /* Extract the option's value if there is one.
-	     * Accept both "--foo bar" and "--foo=bar" style. */
+	    // Extract the option's value if there is one.
+	    // Accept both "--foo bar" and "--foo=bar" style.
 	    if (option->flags & ARG_HAS_VALUE)
 	    {
 		if (argv[i][len] == '=')
@@ -502,7 +502,7 @@
 		    value = argv[i + 1];
 	    }
 
-	    /* Check for options handled by Vim itself */
+	    // Check for options handled by Vim itself
 	    switch (option->flags & ARG_INDEX_MASK)
 	    {
 		case ARG_REVERSE:
@@ -528,11 +528,11 @@
 		    found_iconic_arg = TRUE;
 		    break;
 		case ARG_ROLE:
-		    role_argument = value; /* used later in gui_mch_open() */
+		    role_argument = value; // used later in gui_mch_open()
 		    break;
 #ifdef FEAT_NETBEANS_INTG
 		case ARG_NETBEANS:
-		    gui.dofork = FALSE; /* don't fork() when starting GUI */
+		    gui.dofork = FALSE; // don't fork() when starting GUI
 		    netbeansArg = argv[i];
 		    break;
 #endif
@@ -541,9 +541,9 @@
 	    }
 	}
 
-	/* These arguments make gnome_program_init() print a message and exit.
-	 * Must start the GUI for this, otherwise ":gui" will exit later!
-	 * Only when the GUI can start. */
+	// These arguments make gnome_program_init() print a message and exit.
+	// Must start the GUI for this, otherwise ":gui" will exit later!
+	// Only when the GUI can start.
 	if ((option->flags & ARG_NEEDS_GUI)
 				      && gui_mch_early_init_check(FALSE) == OK)
 	    gui.starting = TRUE;
@@ -552,12 +552,12 @@
 	    ++i;
 	else
 	{
-	    /* Remove the flag from the argument vector. */
+	    // Remove the flag from the argument vector.
 	    if (--*argc > i)
 	    {
 		int n_strip = 1;
 
-		/* Move the argument's value as well, if there is one. */
+		// Move the argument's value as well, if there is one.
 		if ((option->flags & ARG_HAS_VALUE)
 			&& argv[i][len] != '='
 			&& strcmp(argv[i + 1], "--") != 0)
@@ -612,7 +612,7 @@
 			     gui.visibility != GDK_VISIBILITY_UNOBSCURED);
     return FALSE;
 }
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
 
 /*
  * Redraw the corresponding portions of the screen.
@@ -626,7 +626,7 @@
     static void
 gui_gtk3_redraw(int x, int y, int width, int height)
 {
-    /* Range checks are left to gui_redraw_block() */
+    // Range checks are left to gui_redraw_block()
     gui_redraw_block(Y_2_ROW(y), X_2_COL(x),
 	    Y_2_ROW(y + height - 1), X_2_COL(x + width - 1),
 	    GUI_MON_NOCLEAR);
@@ -663,16 +663,16 @@
 	   cairo_t   *cr,
 	   gpointer   user_data UNUSED)
 {
-    /* Skip this when the GUI isn't set up yet, will redraw later. */
+    // Skip this when the GUI isn't set up yet, will redraw later.
     if (gui.starting)
 	return FALSE;
 
-    out_flush();		/* make sure all output has been processed */
-				/* for GTK+ 3, may induce other draw events. */
+    out_flush();		// make sure all output has been processed
+				// for GTK+ 3, may induce other draw events.
 
     cairo_set_source_surface(cr, gui.surface, 0, 0);
 
-    /* Draw the window without the cursor. */
+    // Draw the window without the cursor.
     gui.by_signal = TRUE;
     {
 	cairo_rectangle_list_t *list = NULL;
@@ -682,8 +682,8 @@
 	{
 	    int i;
 
-	    /* First clear all the blocks and then redraw them.  Just in case
-	     * some blocks overlap. */
+	    // First clear all the blocks and then redraw them.  Just in case
+	    // some blocks overlap.
 	    for (i = 0; i < list->num_rectangles; i++)
 	    {
 		const cairo_rectangle_t rect = list->rectangles[i];
@@ -720,27 +720,27 @@
     }
     gui.by_signal = FALSE;
 
-    /* Add the cursor to the window if necessary.*/
+    // Add the cursor to the window if necessary.
     if (gui_gtk3_should_draw_cursor() && blink_mode)
 	gui_gtk3_update_cursor(cr);
 
     return FALSE;
 }
-#else /* !GTK_CHECK_VERSION(3,0,0) */
+#else // !GTK_CHECK_VERSION(3,0,0)
     static gint
 expose_event(GtkWidget *widget UNUSED,
 	     GdkEventExpose *event,
 	     gpointer data UNUSED)
 {
-    /* Skip this when the GUI isn't set up yet, will redraw later. */
+    // Skip this when the GUI isn't set up yet, will redraw later.
     if (gui.starting)
 	return FALSE;
 
-    out_flush();		/* make sure all output has been processed */
+    out_flush();		// make sure all output has been processed
     gui_redraw(event->area.x, event->area.y,
 	       event->area.width, event->area.height);
 
-    /* Clear the border areas if needed */
+    // Clear the border areas if needed
     if (event->area.x < FILL_X(0))
 	gdk_window_clear_area(gui.drawarea->window, 0, 0, FILL_X(0), 0);
     if (event->area.y < FILL_Y(0))
@@ -753,7 +753,7 @@
 
     return FALSE;
 }
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
 
 #ifdef FEAT_CLIENTSERVER
 /*
@@ -771,7 +771,7 @@
     {
 	XEvent xev;
 
-	/* Translate to XLib */
+	// Translate to XLib
 	xev.xproperty.type = PropertyNotify;
 	xev.xproperty.atom = commProperty;
 	xev.xproperty.window = commWindow;
@@ -781,7 +781,7 @@
     }
     return FALSE;
 }
-#endif /* defined(FEAT_CLIENTSERVER) */
+#endif // defined(FEAT_CLIENTSERVER)
 
 /*
  * Handle changes to the "Xft/DPI" setting
@@ -826,9 +826,8 @@
 }
 
 
-/****************************************************************************
- * Focus handlers:
- */
+/////////////////////////////////////////////////////////////////////////////
+// Focus handlers:
 
 
 /*
@@ -931,7 +930,7 @@
     }
     gui_mch_flush();
 
-    return FALSE;		/* don't happen again */
+    return FALSE;		// don't happen again
 }
 
 /*
@@ -946,7 +945,7 @@
 	timeout_remove(blink_timer);
 	blink_timer = 0;
     }
-    /* Only switch blinking on if none of the times is zero */
+    // Only switch blinking on if none of the times is zero
     if (blink_waittime && blink_ontime && blink_offtime && gui.in_focus)
     {
 	blink_timer = timeout_add(blink_waittime, blink_cb, NULL);
@@ -964,7 +963,7 @@
     if (blink_state == BLINK_NONE)
 	gui_mch_start_blink();
 
-    /* make sure keyboard input goes there */
+    // make sure keyboard input goes there
     if (gtk_socket_id == 0 || !gtk_widget_has_focus(gui.drawarea))
 	gtk_widget_grab_focus(gui.drawarea);
 
@@ -992,8 +991,8 @@
     if (blink_state == BLINK_NONE)
 	gui_mch_start_blink();
 
-    /* make sure keyboard input goes to the draw area (if this is focus for a
-     * window) */
+    // make sure keyboard input goes to the draw area (if this is focus for a
+    // window)
     if (widget != gui.drawarea)
 	gtk_widget_grab_focus(gui.drawarea);
 
@@ -1032,13 +1031,13 @@
     uc = gdk_keyval_to_unicode(keyval);
     if (uc != 0)
     {
-	/* Check for CTRL-foo */
+	// Check for CTRL-foo
 	if ((state & GDK_CONTROL_MASK) && uc >= 0x20 && uc < 0x80)
 	{
-	    /* These mappings look arbitrary at the first glance, but in fact
-	     * resemble quite exactly the behaviour of the GTK+ 1.2 GUI on my
-	     * machine.  The only difference is BS vs. DEL for CTRL-8 (makes
-	     * more sense and is consistent with usual terminal behaviour). */
+	    // These mappings look arbitrary at the first glance, but in fact
+	    // resemble quite exactly the behaviour of the GTK+ 1.2 GUI on my
+	    // machine.  The only difference is BS vs. DEL for CTRL-8 (makes
+	    // more sense and is consistent with usual terminal behaviour).
 	    if (uc >= '@')
 		string[0] = uc & 0x1F;
 	    else if (uc == '2')
@@ -1055,16 +1054,16 @@
 	}
 	else
 	{
-	    /* Translate a normal key to UTF-8.  This doesn't work for dead
-	     * keys of course, you _have_ to use an input method for that. */
+	    // Translate a normal key to UTF-8.  This doesn't work for dead
+	    // keys of course, you _have_ to use an input method for that.
 	    len = utf_char2bytes((int)uc, string);
 	}
     }
     else
     {
-	/* Translate keys which are represented by ASCII control codes in Vim.
-	 * There are only a few of those; most control keys are translated to
-	 * special terminal-like control sequences. */
+	// Translate keys which are represented by ASCII control codes in Vim.
+	// There are only a few of those; most control keys are translated to
+	// special terminal-like control sequences.
 	len = 1;
 	switch (keyval)
 	{
@@ -1134,8 +1133,8 @@
 		GdkEventKey *event,
 		gpointer data UNUSED)
 {
-    /* For GTK+ 2 we know for sure how large the string might get.
-     * (That is, up to 6 bytes + NUL + CSI escapes + safety measure.) */
+    // For GTK+ 2 we know for sure how large the string might get.
+    // (That is, up to 6 bytes + NUL + CSI escapes + safety measure.)
     char_u	string[32], string2[32];
     guint	key_sym;
     int		len;
@@ -1172,8 +1171,8 @@
     {
 	len = keyval_to_string(key_sym, state, string2);
 
-	/* Careful: convert_input() doesn't handle the NUL character.
-	 * No need to convert pure ASCII anyway, thus the len > 1 check. */
+	// Careful: convert_input() doesn't handle the NUL character.
+	// No need to convert pure ASCII anyway, thus the len > 1 check.
 	if (len > 1 && input_conv.vc_type != CONV_NONE)
 	    len = convert_input(string2, len, sizeof(string2));
 
@@ -1184,7 +1183,7 @@
 	    *d++ = s[i];
 	    if (d[-1] == CSI && d + 2 < string + sizeof(string))
 	    {
-		/* Turn CSI into K_CSI. */
+		// Turn CSI into K_CSI.
 		*d++ = KS_EXTRA;
 		*d++ = (int)KE_CSI;
 	    }
@@ -1192,7 +1191,7 @@
 	len = d - string;
     }
 
-    /* Shift-Tab results in Left_Tab, but we want <S-Tab> */
+    // Shift-Tab results in Left_Tab, but we want <S-Tab>
     if (key_sym == GDK_ISO_Left_Tab)
     {
 	key_sym = GDK_Tab;
@@ -1200,24 +1199,24 @@
     }
 
 #ifdef FEAT_MENU
-    /* If there is a menu and 'wak' is "yes", or 'wak' is "menu" and the key
-     * is a menu shortcut, we ignore everything with the ALT modifier. */
+    // If there is a menu and 'wak' is "yes", or 'wak' is "menu" and the key
+    // is a menu shortcut, we ignore everything with the ALT modifier.
     if ((state & GDK_MOD1_MASK)
 	    && gui.menu_is_active
 	    && (*p_wak == 'y'
 		|| (*p_wak == 'm'
 		    && len == 1
 		    && gui_is_menu_shortcut(string[0]))))
-	/* For GTK2 we return false to signify that we haven't handled the
-	 * keypress, so that gtk will handle the mnemonic or accelerator. */
+	// For GTK2 we return false to signify that we haven't handled the
+	// keypress, so that gtk will handle the mnemonic or accelerator.
 	return FALSE;
 #endif
 
-    /* Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character
-     * that already has the 8th bit set.
-     * Don't do this for <S-M-Tab>, that should become K_S_TAB with ALT.
-     * Don't do this for double-byte encodings, it turns the char into a lead
-     * byte. */
+    // Check for Alt/Meta key (Mod1Mask), but not for a BS, DEL or character
+    // that already has the 8th bit set.
+    // Don't do this for <S-M-Tab>, that should become K_S_TAB with ALT.
+    // Don't do this for double-byte encodings, it turns the char into a lead
+    // byte.
     if (len == 1
 	    && ((state & GDK_MOD1_MASK)
 #if GTK_CHECK_VERSION(2,10,0)
@@ -1231,8 +1230,8 @@
 	    )
     {
 	string[0] |= 0x80;
-	state &= ~GDK_MOD1_MASK;	/* don't use it again */
-	if (enc_utf8) /* convert to utf-8 */
+	state &= ~GDK_MOD1_MASK;	// don't use it again
+	if (enc_utf8) // convert to utf-8
 	{
 	    string[1] = string[0] & 0xbf;
 	    string[0] = ((unsigned)string[0] >> 6) + 0xc0;
@@ -1247,8 +1246,8 @@
 	}
     }
 
-    /* Check for special keys.	Also do this when len == 1 (key has an ASCII
-     * value) to detect backspace, delete and keypad keys. */
+    // Check for special keys.	Also do this when len == 1 (key has an ASCII
+    // value) to detect backspace, delete and keypad keys.
     if (len == 0 || len == 1)
     {
 	for (i = 0; special_keys[i].key_sym != 0; i++)
@@ -1264,11 +1263,11 @@
 	}
     }
 
-    if (len == 0)   /* Unrecognized key */
+    if (len == 0)   // Unrecognized key
 	return TRUE;
 
-    /* Special keys (and a few others) may have modifiers. Also when using a
-     * double-byte encoding (can't set the 8th bit). */
+    // Special keys (and a few others) may have modifiers. Also when using a
+    // double-byte encoding (can't set the 8th bit).
     if (len == -3 || key_sym == GDK_space || key_sym == GDK_Tab
 	    || key_sym == GDK_Return || key_sym == GDK_Linefeed
 	    || key_sym == GDK_Escape || key_sym == GDK_KP_Tab
@@ -1324,7 +1323,7 @@
 
     add_to_input_buf(string, len);
 
-    /* blank out the pointer if necessary */
+    // blank out the pointer if necessary
     if (p_mh)
 	gui_mch_mousehide(TRUE);
 
@@ -1356,12 +1355,11 @@
 #endif
 
 
-/****************************************************************************
- * Selection handlers:
- */
+/////////////////////////////////////////////////////////////////////////////
+// Selection handlers:
 
-/* Remember when clip_lose_selection was called from here, we must not call
- * gtk_selection_owner_set() then. */
+// Remember when clip_lose_selection was called from here, we must not call
+// gtk_selection_owner_set() then.
 static int in_selection_clear_event = FALSE;
 
     static gint
@@ -1379,9 +1377,9 @@
     return TRUE;
 }
 
-#define RS_NONE	0	/* selection_received_cb() not called yet */
-#define RS_OK	1	/* selection_received_cb() called and OK */
-#define RS_FAIL	2	/* selection_received_cb() called and failed */
+#define RS_NONE	0	// selection_received_cb() not called yet
+#define RS_OK	1	// selection_received_cb() called and OK
+#define RS_FAIL	2	// selection_received_cb() called and failed
 static int received_selection = RS_NONE;
 
     static void
@@ -1408,7 +1406,7 @@
     if (text == NULL || len <= 0)
     {
 	received_selection = RS_FAIL;
-	/* clip_free_selection(cbd); ??? */
+	// clip_free_selection(cbd); ???
 
 	return;
     }
@@ -1430,8 +1428,8 @@
 	text += STRLEN(text) + 1;
 	len -= text - enc;
 
-	/* If the encoding of the text is different from 'encoding', attempt
-	 * converting it. */
+	// If the encoding of the text is different from 'encoding', attempt
+	// converting it.
 	conv.vc_type = CONV_NONE;
 	convert_setup(&conv, enc, p_enc);
 	if (conv.vc_type != CONV_NONE)
@@ -1443,8 +1441,8 @@
 	}
     }
 
-    /* gtk_selection_data_get_text() handles all the nasty details
-     * and targets and encodings etc.  This rocks so hard. */
+    // gtk_selection_data_get_text() handles all the nasty details
+    // and targets and encodings etc.  This rocks so hard.
     else
     {
 	tmpbuf_utf8 = gtk_selection_data_get_text(data);
@@ -1464,7 +1462,7 @@
 	{
 	    vimconv_T conv;
 
-	    /* UTF-16, we get this for HTML */
+	    // UTF-16, we get this for HTML
 	    conv.vc_type = CONV_NONE;
 	    convert_setup_ext(&conv, (char_u *)"utf-16le", FALSE, p_enc, TRUE);
 
@@ -1480,7 +1478,7 @@
 	}
     }
 
-    /* Chop off any trailing NUL bytes.  OpenOffice sends these. */
+    // Chop off any trailing NUL bytes.  OpenOffice sends these.
     while (len > 0 && text[len - 1] == NUL)
 	--len;
 
@@ -1516,7 +1514,7 @@
 	cbd = &clip_star;
 
     if (!cbd->owned)
-	return;			/* Shouldn't ever happen */
+	return;			// Shouldn't ever happen
 
     if (info != (guint)TARGET_STRING
 	    && (!clip_html || info != (guint)TARGET_HTML)
@@ -1527,15 +1525,15 @@
 	    && info != (guint)TARGET_TEXT)
 	return;
 
-    /* get the selection from the '*'/'+' register */
+    // get the selection from the '*'/'+' register
     clip_get_selection(cbd);
 
     motion_type = clip_convert_selection(&string, &tmplen, cbd);
     if (motion_type < 0 || string == NULL)
 	return;
-    /* Due to int arguments we can't handle more than G_MAXINT.  Also
-     * reserve one extra byte for NUL or the motion type; just in case.
-     * (Not that pasting 2G of text is ever going to work, but... ;-) */
+    // Due to int arguments we can't handle more than G_MAXINT.  Also
+    // reserve one extra byte for NUL or the motion type; just in case.
+    // (Not that pasting 2G of text is ever going to work, but... ;-)
     length = MIN(tmplen, (long_u)(G_MAXINT - 1));
 
     if (info == (guint)TARGET_VIM)
@@ -1546,7 +1544,7 @@
 	    tmpbuf[0] = motion_type;
 	    mch_memmove(tmpbuf + 1, string, (size_t)length);
 	}
-	/* For our own format, the first byte contains the motion type */
+	// For our own format, the first byte contains the motion type
 	++length;
 	vim_free(string);
 	string = tmpbuf;
@@ -1557,7 +1555,7 @@
     {
 	vimconv_T conv;
 
-	/* Since we get utf-16, we probably should set it as well. */
+	// Since we get utf-16, we probably should set it as well.
 	conv.vc_type = CONV_NONE;
 	convert_setup_ext(&conv, p_enc, TRUE, (char_u *)"utf-16le", FALSE);
 	if (conv.vc_type != CONV_NONE)
@@ -1568,7 +1566,7 @@
 	    string = tmpbuf;
 	}
 
-	/* Prepend the BOM: "fffe" */
+	// Prepend the BOM: "fffe"
 	if (string != NULL)
 	{
 	    tmpbuf = alloc(length + 2);
@@ -1583,10 +1581,10 @@
 	    }
 
 #if !GTK_CHECK_VERSION(3,0,0)
-	    /* Looks redundant even for GTK2 because these values are
-	     * overwritten by gtk_selection_data_set() that follows. */
+	    // Looks redundant even for GTK2 because these values are
+	    // overwritten by gtk_selection_data_set() that follows.
 	    selection_data->type = selection_data->target;
-	    selection_data->format = 16;	/* 16 bits per char */
+	    selection_data->format = 16;	// 16 bits per char
 #endif
 	    gtk_selection_data_set(selection_data, html_atom, 16,
 							      string, length);
@@ -1598,7 +1596,7 @@
     {
 	int l = STRLEN(p_enc);
 
-	/* contents: motion_type 'encoding' NUL text */
+	// contents: motion_type 'encoding' NUL text
 	tmpbuf = alloc(length + l + 2);
 	if (tmpbuf != NULL)
 	{
@@ -1612,8 +1610,8 @@
 	type = vimenc_atom;
     }
 
-    /* gtk_selection_data_set_text() handles everything for us.  This is
-     * so easy and simple and cool, it'd be insane not to use it. */
+    // gtk_selection_data_set_text() handles everything for us.  This is
+    // so easy and simple and cool, it'd be insane not to use it.
     else
     {
 	if (output_conv.vc_type != CONV_NONE)
@@ -1624,7 +1622,7 @@
 		return;
 	    string = tmpbuf;
 	}
-	/* Validate the string to avoid runtime warnings */
+	// Validate the string to avoid runtime warnings
 	if (g_utf8_validate((const char *)string, (gssize)length, NULL))
 	{
 	    gtk_selection_data_set_text(selection_data,
@@ -1637,10 +1635,10 @@
     if (string != NULL)
     {
 #if !GTK_CHECK_VERSION(3,0,0)
-	/* Looks redundant even for GTK2 because these values are
-	 * overwritten by gtk_selection_data_set() that follows. */
+	// Looks redundant even for GTK2 because these values are
+	// overwritten by gtk_selection_data_set() that follows.
 	selection_data->type = selection_data->target;
-	selection_data->format = 8;	/* 8 bits per char */
+	selection_data->format = 8;	// 8 bits per char
 #endif
 	gtk_selection_data_set(selection_data, type, 8, string, length);
 	vim_free(string);
@@ -1657,7 +1655,7 @@
 {
     char_u *p;
 
-    /* Guess that when $DISPLAY isn't set the GUI can't start. */
+    // Guess that when $DISPLAY isn't set the GUI can't start.
     p = mch_getenv((char_u *)"DISPLAY");
     if (p == NULL || *p == NUL)
     {
@@ -1682,16 +1680,16 @@
 
     if (!res_registered)
     {
-	/* Call this function in the GUI process; otherwise, the resources
-	 * won't be available.  Don't call it twice. */
+	// Call this function in the GUI process; otherwise, the resources
+	// won't be available.  Don't call it twice.
 	res_registered = TRUE;
 	gui_gtk_register_resource();
     }
 #endif
 
 #if GTK_CHECK_VERSION(3,10,0)
-    /* Vim currently assumes that Gtk means X11, so it cannot use native Gtk
-     * support for other backends such as Wayland. */
+    // Vim currently assumes that Gtk means X11, so it cannot use native Gtk
+    // support for other backends such as Wayland.
     gdk_set_allowed_backends ("x11");
 #endif
 
@@ -1700,12 +1698,12 @@
 	using_gnome = 1;
 #endif
 
-    /* This defaults to argv[0], but we want it to match the name of the
-     * shipped gvim.desktop so that Vim's windows can be associated with this
-     * file. */
+    // This defaults to argv[0], but we want it to match the name of the
+    // shipped gvim.desktop so that Vim's windows can be associated with this
+    // file.
     g_set_prgname("gvim");
 
-    /* Don't use gtk_init() or gnome_init(), it exits on failure. */
+    // Don't use gtk_init() or gnome_init(), it exits on failure.
     if (!gtk_init_check(&gui_argc, &gui_argv))
     {
 	gui.dying = TRUE;
@@ -1716,9 +1714,8 @@
     return OK;
 }
 
-/****************************************************************************
- * Mouse handling callbacks
- */
+/////////////////////////////////////////////////////////////////////////////
+// Mouse handling callbacks
 
 
 static guint mouse_click_timer = 0;
@@ -1730,11 +1727,11 @@
     static timeout_cb_type
 mouse_click_timer_cb(gpointer data)
 {
-    /* we don't use this information currently */
+    // we don't use this information currently
     int *timed_out = (int *) data;
 
     *timed_out = TRUE;
-    return FALSE;		/* don't happen again */
+    return FALSE;		// don't happen again
 }
 
 static guint		motion_repeat_timer  = 0;
@@ -1753,21 +1750,21 @@
 		       GDK_BUTTON5_MASK))
 	      ? MOUSE_DRAG : ' ';
 
-    /* If our pointer is currently hidden, then we should show it. */
+    // If our pointer is currently hidden, then we should show it.
     gui_mch_mousehide(FALSE);
 
-    /* Just moving the rodent above the drawing area without any button
-     * being pressed. */
+    // Just moving the rodent above the drawing area without any button
+    // being pressed.
     if (button != MOUSE_DRAG)
     {
 	gui_mouse_moved(x, y);
 	return;
     }
 
-    /* translate modifier coding between the main engine and GTK */
+    // translate modifier coding between the main engine and GTK
     vim_modifiers = modifiers_gdk2mouse(state);
 
-    /* inform the editor engine about the occurrence of this event */
+    // inform the editor engine about the occurrence of this event
     gui_send_mouse_event(button, x, y, FALSE, vim_modifiers);
 
     /*
@@ -1785,26 +1782,24 @@
 	int offshoot;
 	int delay = 10;
 
-	/* Calculate the maximal distance of the cursor from the drawing area.
-	 * (offshoot can't become negative here!).
-	 */
+	// Calculate the maximal distance of the cursor from the drawing area.
+	// (offshoot can't become negative here!).
 	dx = x < 0 ? -x : x - allocation.width;
 	dy = y < 0 ? -y : y - allocation.height;
 
 	offshoot = dx > dy ? dx : dy;
 
-	/* Make a linearly decaying timer delay with a threshold of 5 at a
-	 * distance of 127 pixels from the main window.
-	 *
-	 * One could think endlessly about the most ergonomic variant here.
-	 * For example it could make sense to calculate the distance from the
-	 * drags start instead...
-	 *
-	 * Maybe a parabolic interpolation would suite us better here too...
-	 */
+	// Make a linearly decaying timer delay with a threshold of 5 at a
+	// distance of 127 pixels from the main window.
+	//
+	// One could think endlessly about the most ergonomic variant here.
+	// For example it could make sense to calculate the distance from the
+	// drags start instead...
+	//
+	// Maybe a parabolic interpolation would suite us better here too...
 	if (offshoot > 127)
 	{
-	    /* 5 appears to be somehow near to my perceptual limits :-). */
+	    // 5 appears to be somehow near to my perceptual limits :-).
 	    delay = 5;
 	}
 	else
@@ -1812,7 +1807,7 @@
 	    delay = (130 * (127 - offshoot)) / 127 + 5;
 	}
 
-	/* shoot again */
+	// shoot again
 	if (!motion_repeat_timer)
 	    motion_repeat_timer = timeout_add(delay, motion_repeat_timer_cb,
 									 NULL);
@@ -1855,7 +1850,7 @@
     return gdk_device_get_window_at_position(dev, x, y);
 }
 # endif
-#else /* !GTK_CHECK_VERSION(3,0,0) */
+#else // !GTK_CHECK_VERSION(3,0,0)
 # define gui_gtk_get_pointer(wid, x, y, s) \
     gdk_window_get_pointer((wid)->window, x, y, s)
 # define gui_gtk_window_at_position(wid, x, y)	gdk_window_at_pointer(x, y)
@@ -1881,8 +1876,8 @@
 	return FALSE;
     }
 
-    /* If there already is a mouse click in the input buffer, wait another
-     * time (otherwise we would create a backlog of clicks) */
+    // If there already is a mouse click in the input buffer, wait another
+    // time (otherwise we would create a backlog of clicks)
     if (vim_used_in_input_buf() > 10)
 	return TRUE;
 
@@ -1900,8 +1895,8 @@
     motion_repeat_offset = !motion_repeat_offset;
     process_motion_notify(x, y, state);
 
-    /* Don't happen again.  We will get reinstalled in the synthetic event
-     * if needed -- thus repeating should still work. */
+    // Don't happen again.  We will get reinstalled in the synthetic event
+    // if needed -- thus repeating should still work.
     return FALSE;
 }
 
@@ -1925,7 +1920,7 @@
 			      (GdkModifierType)event->state);
     }
 
-    return TRUE; /* handled */
+    return TRUE; // handled
 }
 
 
@@ -1946,7 +1941,7 @@
 
     gui.event_time = event->time;
 
-    /* Make sure we have focus now we've been selected */
+    // Make sure we have focus now we've been selected
     if (gtk_socket_id != 0 && !gtk_widget_has_focus(widget))
 	gtk_widget_grab_focus(widget);
 
@@ -1960,7 +1955,7 @@
     x = event->x;
     y = event->y;
 
-    /* Handle multiple clicks */
+    // Handle multiple clicks
     if (!mouse_timed_out && mouse_click_timer)
     {
 	timeout_remove(mouse_click_timer);
@@ -1974,19 +1969,19 @@
 
     switch (event->button)
     {
-	/* Keep in sync with gui_x11.c.
-	 * Buttons 4-7 are handled in scroll_event() */
+	// Keep in sync with gui_x11.c.
+	// Buttons 4-7 are handled in scroll_event()
 	case 1: button = MOUSE_LEFT; break;
 	case 2: button = MOUSE_MIDDLE; break;
 	case 3: button = MOUSE_RIGHT; break;
 	case 8: button = MOUSE_X1; break;
 	case 9: button = MOUSE_X2; break;
 	default:
-	    return FALSE;		/* Unknown button */
+	    return FALSE;		// Unknown button
     }
 
 #ifdef FEAT_XIM
-    /* cancel any preediting */
+    // cancel any preediting
     if (im_is_preediting())
 	xim_reset();
 #endif
@@ -2026,12 +2021,12 @@
 	case GDK_SCROLL_RIGHT:
 	    button = MOUSE_6;
 	    break;
-	default: /* This shouldn't happen */
+	default: // This shouldn't happen
 	    return FALSE;
     }
 
 # ifdef FEAT_XIM
-    /* cancel any preediting */
+    // cancel any preediting
     if (im_is_preediting())
 	xim_reset();
 # endif
@@ -2055,9 +2050,9 @@
 
     gui.event_time = event->time;
 
-    /* Remove any motion "machine gun" timers used for automatic further
-       extension of allocation areas if outside of the applications window
-       area .*/
+    // Remove any motion "machine gun" timers used for automatic further
+    // extension of allocation areas if outside of the applications window
+    // area .
     if (motion_repeat_timer)
     {
 	timeout_remove(motion_repeat_timer);
@@ -2076,9 +2071,8 @@
 
 
 #ifdef FEAT_DND
-/****************************************************************************
- * Drag aNd Drop support handlers.
- */
+/////////////////////////////////////////////////////////////////////////////
+// Drag aNd Drop support handlers.
 
 /*
  * Count how many items there may be and separate them with a NUL.
@@ -2113,7 +2107,7 @@
     }
     if (p > out && p[-1] != NUL)
     {
-	*p = NUL;	/* last item didn't have \r or \n */
+	*p = NUL;	// last item didn't have \r or \n
 	++count;
     }
     return count;
@@ -2183,7 +2177,7 @@
     {
 	int_u   modifiers;
 
-	gtk_drag_finish(context, TRUE, FALSE, time_); /* accept */
+	gtk_drag_finish(context, TRUE, FALSE, time_); // accept
 
 	modifiers = modifiers_gdk2mouse(state);
 
@@ -2216,7 +2210,7 @@
     }
 
     dnd_yank_drag_data(text, (long)len);
-    gtk_drag_finish(context, TRUE, FALSE, time_); /* accept */
+    gtk_drag_finish(context, TRUE, FALSE, time_); // accept
     vim_free(tmpbuf);
 
     dropkey[2] = modifiers_gdk2vim(state);
@@ -2242,7 +2236,7 @@
 {
     GdkModifierType state;
 
-    /* Guard against trash */
+    // Guard against trash
     const guchar * const data_data = gtk_selection_data_get_data(data);
     const gint data_length = gtk_selection_data_get_length(data);
     const gint data_format = gtk_selection_data_get_format(data);
@@ -2256,18 +2250,18 @@
 	return;
     }
 
-    /* Get the current modifier state for proper distinguishment between
-     * different operations later. */
+    // Get the current modifier state for proper distinguishment between
+    // different operations later.
     gui_gtk_get_pointer(widget, NULL, NULL, &state);
 
-    /* Not sure about the role of "text/plain" here... */
+    // Not sure about the role of "text/plain" here...
     if (info == (guint)TARGET_TEXT_URI_LIST)
 	drag_handle_uri_list(context, data, time_, state, x, y);
     else
 	drag_handle_text(context, data, time_, state);
 
 }
-#endif /* FEAT_DND */
+#endif // FEAT_DND
 
 
 #if defined(USE_GNOME_SESSION)
@@ -2301,7 +2295,7 @@
 
     exiting = FALSE;
     cmdmod = save_cmdmod;
-    setcursor(); /* position the cursor */
+    setcursor(); // position the cursor
     out_flush();
     /*
      * If the user hit the [Cancel] button the whole shutdown
@@ -2329,26 +2323,26 @@
     unsigned int	len;
     gboolean		success;
 
-    /* Always request an interaction if possible.  check_changed_any()
-     * won't actually show a dialog unless any buffers have been modified.
-     * There doesn't seem to be an obvious way to check that without
-     * automatically firing the dialog.  Anyway, it works just fine. */
+    // Always request an interaction if possible.  check_changed_any()
+    // won't actually show a dialog unless any buffers have been modified.
+    // There doesn't seem to be an obvious way to check that without
+    // automatically firing the dialog.  Anyway, it works just fine.
     if (interact_style == GNOME_INTERACT_ANY)
 	gnome_client_request_interaction(client, GNOME_DIALOG_NORMAL,
 					 &sm_client_check_changed_any,
 					 NULL);
     out_flush();
-    ml_sync_all(FALSE, FALSE); /* preserve all swap files */
+    ml_sync_all(FALSE, FALSE); // preserve all swap files
 
-    /* The path is unique for each session save.  We do neither know nor care
-     * which session script will actually be used later.  This decision is in
-     * the domain of the session manager. */
+    // The path is unique for each session save.  We do neither know nor care
+    // which session script will actually be used later.  This decision is in
+    // the domain of the session manager.
     session_file = gnome_config_get_real_path(
 			gnome_client_get_config_prefix(client));
     len = strlen(session_file);
 
     if (len > 0 && session_file[len-1] == G_DIR_SEPARATOR)
-	--len; /* get rid of the superfluous trailing '/' */
+	--len; // get rid of the superfluous trailing '/'
 
     session_file = g_renew(char, session_file, len + sizeof(suffix));
     memcpy(session_file + len, suffix, sizeof(suffix));
@@ -2360,10 +2354,10 @@
 	const char  *argv[8];
 	int	    i;
 
-	/* Tell the session manager how to wipe out the stored session data.
-	 * This isn't as dangerous as it looks, don't worry :)	session_file
-	 * is a unique absolute filename.  Usually it'll be something like
-	 * `/home/user/.gnome2/vim-XXXXXX-session.vim'. */
+	// Tell the session manager how to wipe out the stored session data.
+	// This isn't as dangerous as it looks, don't worry :)	session_file
+	// is a unique absolute filename.  Usually it'll be something like
+	// `/home/user/.gnome2/vim-XXXXXX-session.vim'.
 	i = 0;
 	argv[i++] = "rm";
 	argv[i++] = session_file;
@@ -2371,11 +2365,11 @@
 
 	gnome_client_set_discard_command(client, i, (char **)argv);
 
-	/* Tell the session manager how to restore the just saved session.
-	 * This is easily done thanks to Vim's -S option.  Pass the -f flag
-	 * since there's no need to fork -- it might even cause confusion.
-	 * Also pass the window role to give the WM something to match on.
-	 * The role is set in gui_mch_open(), thus should _never_ be NULL. */
+	// Tell the session manager how to restore the just saved session.
+	// This is easily done thanks to Vim's -S option.  Pass the -f flag
+	// since there's no need to fork -- it might even cause confusion.
+	// Also pass the window role to give the WM something to match on.
+	// The role is set in gui_mch_open(), thus should _never_ be NULL.
 	i = 0;
 	argv[i++] = restart_command;
 	argv[i++] = "-f";
@@ -2403,7 +2397,7 @@
     static void
 sm_client_die(GnomeClient *client UNUSED, gpointer data UNUSED)
 {
-    /* Don't write messages to the GUI anymore */
+    // Don't write messages to the GUI anymore
     full_screen = FALSE;
 
     vim_strncpy(IObuff, (char_u *)
@@ -2424,8 +2418,8 @@
 
     if (client != NULL)
     {
-	/* Must use the deprecated gtk_signal_connect() for compatibility
-	 * with GNOME 1.  Arrgh, zombies! */
+	// Must use the deprecated gtk_signal_connect() for compatibility
+	// with GNOME 1.  Arrgh, zombies!
 	gtk_signal_connect(GTK_OBJECT(client), "save_yourself",
 			   GTK_SIGNAL_FUNC(&sm_client_save_yourself), NULL);
 	gtk_signal_connect(GTK_OBJECT(client), "die",
@@ -2447,17 +2441,17 @@
 {
     if (condition == G_IO_IN)
     {
-	/* Do stuff; maybe close connection */
+	// Do stuff; maybe close connection
 	if (xsmp_handle_requests() == FAIL)
 	    g_io_channel_unref((GIOChannel *)data);
 	return TRUE;
     }
-    /* Error */
+    // Error
     g_io_channel_unref((GIOChannel *)data);
     xsmp_close();
     return TRUE;
 }
-# endif /* USE_XSMP */
+# endif // USE_XSMP
 
 /*
  * Setup the WM_PROTOCOLS to indicate we want the WM_SAVE_YOURSELF event.
@@ -2485,9 +2479,9 @@
     else
 # endif
     {
-	/* Fall back to old method */
+	// Fall back to old method
 
-	/* first get the existing value */
+	// first get the existing value
 	GdkWindow * const mainwin_win = gtk_widget_get_window(gui.mainwin);
 
 	if (XGetWMProtocols(GDK_WINDOW_XDISPLAY(mainwin_win),
@@ -2500,14 +2494,14 @@
 
 	    save_yourself_xatom = GET_X_ATOM(save_yourself_atom);
 
-	    /* check if WM_SAVE_YOURSELF isn't there yet */
+	    // check if WM_SAVE_YOURSELF isn't there yet
 	    for (i = 0; i < count; ++i)
 		if (existing_atoms[i] == save_yourself_xatom)
 		    break;
 
 	    if (i == count)
 	    {
-		/* allocate an Atoms array which is one item longer */
+		// allocate an Atoms array which is one item longer
 		new_atoms = ALLOC_MULT(Atom, count + 1);
 		if (new_atoms != NULL)
 		{
@@ -2553,7 +2547,7 @@
 					    == GET_X_ATOM(save_yourself_atom))
     {
 	out_flush();
-	ml_sync_all(FALSE, FALSE); /* preserve all swap files */
+	ml_sync_all(FALSE, FALSE); // preserve all swap files
 	/*
 	 * Set the window's WM_COMMAND property, to let the window manager
 	 * know we are done saving ourselves.  We don't want to be
@@ -2576,12 +2570,12 @@
     static void
 mainwin_realize(GtkWidget *widget UNUSED, gpointer data UNUSED)
 {
-/* If you get an error message here, you still need to unpack the runtime
- * archive! */
+// If you get an error message here, you still need to unpack the runtime
+// archive!
 #ifdef magick
 # undef magick
 #endif
-  /* A bit hackish, but avoids casting later and allows optimization */
+  // A bit hackish, but avoids casting later and allows optimization
 # define static static const
 #define magick vim32x32
 #include "../runtime/vim32x32.xpm"
@@ -2596,7 +2590,7 @@
 
     GdkWindow * const mainwin_win = gtk_widget_get_window(gui.mainwin);
 
-    /* When started with "--echo-wid" argument, write window ID on stdout. */
+    // When started with "--echo-wid" argument, write window ID on stdout.
     if (echo_wid_arg)
     {
 	printf("WID: %ld\n", (long)GDK_WINDOW_XID(mainwin_win));
@@ -2621,12 +2615,12 @@
     }
 
 #if !defined(USE_GNOME_SESSION)
-    /* Register a handler for WM_SAVE_YOURSELF with GDK's low-level X I/F */
+    // Register a handler for WM_SAVE_YOURSELF with GDK's low-level X I/F
     gdk_window_add_filter(NULL, &global_event_filter, NULL);
 #endif
-    /* Setup to indicate to the window manager that we want to catch the
-     * WM_SAVE_YOURSELF event.	For GNOME, this connects to the session
-     * manager instead. */
+    // Setup to indicate to the window manager that we want to catch the
+    // WM_SAVE_YOURSELF event.	For GNOME, this connects to the session
+    // manager instead.
 #if defined(USE_GNOME_SESSION)
     if (using_gnome)
 #endif
@@ -2635,7 +2629,7 @@
 #ifdef FEAT_CLIENTSERVER
     if (serverName == NULL && serverDelayedStartName != NULL)
     {
-	/* This is a :gui command in a plain vim with no previous server */
+	// This is a :gui command in a plain vim with no previous server
 	commWindow = GDK_WINDOW_XID(mainwin_win);
 
 	(void)serverRegisterName(GDK_WINDOW_XDISPLAY(mainwin_win),
@@ -2684,8 +2678,8 @@
     root_window = gtk_widget_get_root_window(gui.mainwin);
 #endif
 
-    /* Create a pseudo blank pointer, which is in fact one pixel by one pixel
-     * in size. */
+    // Create a pseudo blank pointer, which is in fact one pixel by one pixel
+    // in size.
 #if GTK_CHECK_VERSION(3,0,0)
     {
 	cairo_surface_t *surf;
@@ -2792,7 +2786,7 @@
     if (gui.pointer_hidden)
 	gdk_window_set_cursor(gtk_widget_get_window(widget), gui.blank_pointer);
 
-    /* get the actual size of the scrollbars, if they are realized */
+    // get the actual size of the scrollbars, if they are realized
     sbar = firstwin->w_scrollbars[SBAR_LEFT].id;
     if (!sbar || (!gui.which_scrollbars[SBAR_LEFT]
 				    && firstwin->w_scrollbars[SBAR_RIGHT].id))
@@ -2812,7 +2806,7 @@
     static void
 drawarea_unrealize_cb(GtkWidget *widget UNUSED, gpointer data UNUSED)
 {
-    /* Don't write messages to the GUI anymore */
+    // Don't write messages to the GUI anymore
     full_screen = FALSE;
 
 #ifdef FEAT_XIM
@@ -2877,30 +2871,30 @@
 	    && event->width >= 1 && event->height >= 1, TRUE);
 
 # if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4)
-    /* As of 3.22.2, GdkWindows have started distributing configure events to
-     * their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0).
-     *
-     * As can be seen from the implementation of move_native_children() and
-     * configure_native_child() in gdkwindow.c, those functions actually
-     * propagate configure events to every child, failing to distinguish
-     * "native" one from non-native one.
-     *
-     * Naturally, configure events propagated to here like that are fallacious
-     * and, as a matter of fact, they trigger a geometric collapse of
-     * gui.drawarea in fullscreen and maximized modes.
-     *
-     * To filter out such nuisance events, we are making use of the fact that
-     * the field send_event of such GdkEventConfigures is set to FALSE in
-     * configure_native_child().
-     *
-     * Obviously, this is a terrible hack making GVim depend on GTK's
-     * implementation details.  Therefore, watch out any relevant internal
-     * changes happening in GTK in the feature (sigh).
-     */
-    /* Follow-up
-     * After a few weeks later, the GdkWindow change mentioned above was
-     * reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155).
-     * The corresponding official release is 3.22.4. */
+    // As of 3.22.2, GdkWindows have started distributing configure events to
+    // their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0).
+    //
+    // As can be seen from the implementation of move_native_children() and
+    // configure_native_child() in gdkwindow.c, those functions actually
+    // propagate configure events to every child, failing to distinguish
+    // "native" one from non-native one.
+    //
+    // Naturally, configure events propagated to here like that are fallacious
+    // and, as a matter of fact, they trigger a geometric collapse of
+    // gui.drawarea in fullscreen and maximized modes.
+    //
+    // To filter out such nuisance events, we are making use of the fact that
+    // the field send_event of such GdkEventConfigures is set to FALSE in
+    // configure_native_child().
+    //
+    // Obviously, this is a terrible hack making GVim depend on GTK's
+    // implementation details.  Therefore, watch out any relevant internal
+    // changes happening in GTK in the feature (sigh).
+    //
+    // Follow-up
+    // After a few weeks later, the GdkWindow change mentioned above was
+    // reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155).
+    // The corresponding official release is 3.22.4.
     if (event->send_event == FALSE)
 	return TRUE;
 # endif
@@ -2953,8 +2947,8 @@
 	parent	 = gtk_widget_get_parent(widget);
 	if (G_TYPE_FROM_INSTANCE(parent) == BONOBO_TYPE_DOCK_ITEM)
 	{
-	    /* Only menu & toolbar are dock items.  Could tabline be?
-	     * Seem to be only the 2 defined in GNOME */
+	    // Only menu & toolbar are dock items.  Could tabline be?
+	    // Seem to be only the 2 defined in GNOME
 	    widget = parent;
 	    dockitem = BONOBO_DOCK_ITEM(widget);
 
@@ -2993,7 +2987,7 @@
 {
     int width = 0;
 
-#ifdef FEAT_GUI_GNOME /* these are never vertical without GNOME */
+#ifdef FEAT_GUI_GNOME // these are never vertical without GNOME
 # ifdef FEAT_MENU
     width += get_item_dimensions(gui.menubar, GTK_ORIENTATION_VERTICAL);
 # endif
@@ -3028,12 +3022,11 @@
     return height;
 }
 
-/* This controls whether we can set the real window hints at
- * start-up when in a GtkPlug.
- * 0 = normal processing (default)
- * 1 = init. hints set, no-one's tried to reset since last check
- * 2 = init. hints set, attempt made to change hints
- */
+// This controls whether we can set the real window hints at
+// start-up when in a GtkPlug.
+// 0 = normal processing (default)
+// 1 = init. hints set, no-one's tried to reset since last check
+// 2 = init. hints set, attempt made to change hints
 static int init_window_hints_state = 0;
 
     static void
@@ -3051,19 +3044,18 @@
     int min_width;
     int min_height;
 
-    /* At start-up, don't try to set the hints until the initial
-     * values have been used (those that dictate our initial size)
-     * Let forced (i.e., correct) values through always.
-     */
+    // At start-up, don't try to set the hints until the initial
+    // values have been used (those that dictate our initial size)
+    // Let forced (i.e., correct) values through always.
     if (!(force_width && force_height)  &&  init_window_hints_state > 0)
     {
-	/* Don't do it! */
+	// Don't do it!
 	init_window_hints_state = 2;
 	return;
     }
 
-    /* This also needs to be done when the main window isn't there yet,
-     * otherwise the hints don't work. */
+    // This also needs to be done when the main window isn't there yet,
+    // otherwise the hints don't work.
     width  = gui_get_base_width();
     height = gui_get_base_height();
 # ifdef FEAT_MENU
@@ -3072,12 +3064,11 @@
     width  += get_menu_tool_width();
     height += get_menu_tool_height();
 
-    /* GtkSockets use GtkPlug's [gui,mainwin] min-size hints to determine
-     * their actual widget size.  When we set our size ourselves (e.g.,
-     * 'set columns=' or init. -geom) we briefly set the min. to the size
-     * we wish to be instead of the legitimate minimum so that we actually
-     * resize correctly.
-     */
+    // GtkSockets use GtkPlug's [gui,mainwin] min-size hints to determine
+    // their actual widget size.  When we set our size ourselves (e.g.,
+    // 'set columns=' or init. -geom) we briefly set the min. to the size
+    // we wish to be instead of the legitimate minimum so that we actually
+    // resize correctly.
     if (force_width && force_height)
     {
 	min_width  = force_width;
@@ -3089,7 +3080,7 @@
 	min_height = height + MIN_LINES   * gui.char_height;
     }
 
-    /* Avoid an expose event when the size didn't change. */
+    // Avoid an expose event when the size didn't change.
     if (width != old_width
 	    || height != old_height
 	    || min_width != old_min_width
@@ -3108,9 +3099,9 @@
 	geometry.min_height  = min_height;
 	geometry_mask	     = GDK_HINT_BASE_SIZE|GDK_HINT_RESIZE_INC
 			       |GDK_HINT_MIN_SIZE;
-	/* Using gui.formwin as geometry widget doesn't work as expected
-	 * with GTK+ 2 -- dunno why.  Presumably all the resizing hacks
-	 * in Vim confuse GTK+. */
+	// Using gui.formwin as geometry widget doesn't work as expected
+	// with GTK+ 2 -- dunno why.  Presumably all the resizing hacks
+	// in Vim confuse GTK+.
 	gtk_window_set_geometry_hints(GTK_WINDOW(gui.mainwin), gui.mainwin,
 				      &geometry, geometry_mask);
 	old_width       = width;
@@ -3133,7 +3124,7 @@
     g_object_set(gtk_settings, "gtk-application-prefer-dark-theme", (gboolean)dark, NULL);
 # endif
 }
-#endif /* FEAT_GUI_DARKTHEME */
+#endif // FEAT_GUI_DARKTHEME
 
 #ifdef FEAT_TOOLBAR
 
@@ -3160,7 +3151,7 @@
 	    gtk_image_set_from_icon_name(image, icon_name, icon_size);
 	}
 # else
-	/* User-defined icons are stored in a GtkIconSet */
+	// User-defined icons are stored in a GtkIconSet
 	if (gtk_image_get_storage_type(image) == GTK_IMAGE_ICON_SET)
 	{
 	    GtkIconSet	*icon_set;
@@ -3220,7 +3211,7 @@
 
     if (size == GTK_ICON_SIZE_INVALID)
     {
-	/* Let global user preferences decide the icon size. */
+	// Let global user preferences decide the icon size.
 	gtk_toolbar_unset_icon_size(toolbar);
 	size = gtk_toolbar_get_icon_size(toolbar);
     }
@@ -3233,7 +3224,7 @@
     gtk_toolbar_set_icon_size(toolbar, size);
 }
 
-#endif /* FEAT_TOOLBAR */
+#endif // FEAT_TOOLBAR
 
 #if defined(FEAT_GUI_TABLINE) || defined(PROTO)
 static int ignore_tabline_evt = FALSE;
@@ -3241,7 +3232,7 @@
 # if !GTK_CHECK_VERSION(3,0,0)
 static GtkTooltips *tabline_tooltip;
 # endif
-static int clicked_page;	    /* page clicked in tab line */
+static int clicked_page;	    // page clicked in tab line
 
 /*
  * Handle selecting an item in the tab line popup menu.
@@ -3249,7 +3240,7 @@
     static void
 tabline_menu_handler(GtkMenuItem *item UNUSED, gpointer user_data)
 {
-    /* Add the string cmd into input buffer */
+    // Add the string cmd into input buffer
     send_tabline_menu_event(clicked_page, (int)(long)user_data);
 }
 
@@ -3289,7 +3280,7 @@
     static gboolean
 on_tabline_menu(GtkWidget *widget, GdkEvent *event)
 {
-    /* Was this button press event ? */
+    // Was this button press event ?
     if (event->type == GDK_BUTTON_PRESS)
     {
 	GdkEventButton *bevent = (GdkEventButton *)event;
@@ -3298,8 +3289,8 @@
 	GtkWidget	*tabwidget;
 	GdkWindow	*tabwin;
 
-	/* When ignoring events return TRUE so that the selected page doesn't
-	 * change. */
+	// When ignoring events return TRUE so that the selected page doesn't
+	// change.
 	if (hold_gui_events
 # ifdef FEAT_CMDWIN
 		|| cmdwin_type != 0
@@ -3313,7 +3304,7 @@
 	clicked_page = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(tabwidget),
 							 "tab_num"));
 
-	/* If the event was generated for 3rd button popup the menu. */
+	// If the event was generated for 3rd button popup the menu.
 	if (bevent->button == 3)
 	{
 # if GTK_CHECK_VERSION(3,22,2)
@@ -3322,21 +3313,21 @@
 	    gtk_menu_popup(GTK_MENU(widget), NULL, NULL, NULL, NULL,
 						bevent->button, bevent->time);
 # endif
-	    /* We handled the event. */
+	    // We handled the event.
 	    return TRUE;
 	}
 	else if (bevent->button == 1)
 	{
 	    if (clicked_page == 0)
 	    {
-		/* Click after all tabs moves to next tab page.  When "x" is
-		 * small guess it's the left button. */
+		// Click after all tabs moves to next tab page.  When "x" is
+		// small guess it's the left button.
 		send_tabline_event(x < 50 ? -1 : 0);
 	    }
 	}
     }
 
-    /* We didn't handle the event. */
+    // We didn't handle the event.
     return FALSE;
 }
 
@@ -3386,7 +3377,7 @@
 
     if (!showit != !gtk_notebook_get_show_tabs(GTK_NOTEBOOK(gui.tabline)))
     {
-	/* Note: this may cause a resize event */
+	// Note: this may cause a resize event
 	gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gui.tabline), showit);
 	update_window_manager_hints(0, 0);
 	if (showit)
@@ -3426,7 +3417,7 @@
 
     ignore_tabline_evt = TRUE;
 
-    /* Add a label for each tab page.  They all contain the same text area. */
+    // Add a label for each tab page.  They all contain the same text area.
     for (tp = first_tabpage; tp != NULL; tp = tp->tp_next, ++nr)
     {
 	if (tp == curtab)
@@ -3437,7 +3428,7 @@
 	page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr);
 	if (page == NULL)
 	{
-	    /* Add notebook page */
+	    // Add notebook page
 # if GTK_CHECK_VERSION(3,2,0)
 	    page = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
 	    gtk_box_set_homogeneous(GTK_BOX(page), FALSE);
@@ -3484,14 +3475,14 @@
 	CONVERT_TO_UTF8_FREE(labeltext);
     }
 
-    /* Remove any old labels. */
+    // Remove any old labels.
     while (gtk_notebook_get_nth_page(GTK_NOTEBOOK(gui.tabline), nr) != NULL)
 	gtk_notebook_remove_page(GTK_NOTEBOOK(gui.tabline), nr);
 
     if (gtk_notebook_get_current_page(GTK_NOTEBOOK(gui.tabline)) != curtabidx)
 	gtk_notebook_set_current_page(GTK_NOTEBOOK(gui.tabline), curtabidx);
 
-    /* Make sure everything is in place before drawing text. */
+    // Make sure everything is in place before drawing text.
     gui_mch_update();
 
     ignore_tabline_evt = FALSE;
@@ -3512,7 +3503,7 @@
     ignore_tabline_evt = FALSE;
 }
 
-#endif /* FEAT_GUI_TABLINE */
+#endif // FEAT_GUI_TABLINE
 
 /*
  * Add selection targets for PRIMARY and CLIPBOARD selections.
@@ -3526,9 +3517,9 @@
 
     for (i = 0; i < (int)N_SELECTION_TARGETS; ++i)
     {
-	/* OpenOffice tries to use TARGET_HTML and fails when we don't
-	 * return something, instead of trying another target. Therefore only
-	 * offer TARGET_HTML when it works. */
+	// OpenOffice tries to use TARGET_HTML and fails when we don't
+	// return something, instead of trying another target. Therefore only
+	// offer TARGET_HTML when it works.
 	if (!clip_html && selection_targets[i].info == TARGET_HTML)
 	    n_targets--;
 	else
@@ -3580,9 +3571,9 @@
     GtkWidget *vbox;
 
 #ifdef FEAT_GUI_GNOME
-    /* Initialize the GNOME libraries.	gnome_program_init()/gnome_init()
-     * exits on failure, but that's a non-issue because we already called
-     * gtk_init_check() in gui_mch_init_check(). */
+    // Initialize the GNOME libraries.	gnome_program_init()/gnome_init()
+    // exits on failure, but that's a non-issue because we already called
+    // gtk_init_check() in gui_mch_init_check().
     if (using_gnome)
     {
 	gnome_program_init(VIMPACKAGE, VIM_VERSION_SHORT,
@@ -3591,8 +3582,8 @@
 	{
 	    char *p = setlocale(LC_NUMERIC, NULL);
 
-	    /* Make sure strtod() uses a decimal point, not a comma. Gnome
-	     * init may change it. */
+	    // Make sure strtod() uses a decimal point, not a comma. Gnome
+	    // init may change it.
 	    if (p == NULL || strcmp(p, "C") != 0)
 	       setlocale(LC_NUMERIC, "C");
 	}
@@ -3602,7 +3593,7 @@
     VIM_CLEAR(gui_argv);
 
 #if GLIB_CHECK_VERSION(2,1,3)
-    /* Set the human-readable application name */
+    // Set the human-readable application name
     g_set_application_name("Vim");
 #endif
     /*
@@ -3615,15 +3606,15 @@
 #ifdef FEAT_TOOLBAR
     gui_gtk_register_stock_icons();
 #endif
-    /* FIXME: Need to install the classic icons and a gtkrc.classic file.
-     * The hard part is deciding install locations and the Makefile magic. */
+    // FIXME: Need to install the classic icons and a gtkrc.classic file.
+    // The hard part is deciding install locations and the Makefile magic.
 #if !GTK_CHECK_VERSION(3,0,0)
 # if 0
     gtk_rc_parse("gtkrc");
 # endif
 #endif
 
-    /* Initialize values */
+    // Initialize values
     gui.border_width = 2;
     gui.scrollbar_width = SB_DEFAULT_WIDTH;
     gui.scrollbar_height = SB_DEFAULT_WIDTH;
@@ -3632,19 +3623,19 @@
     gui.bgcolor = g_new(GdkRGBA, 1);
     gui.spcolor = g_new(GdkRGBA, 1);
 #else
-    /* LINTED: avoid warning: conversion to 'unsigned long' */
+    // LINTED: avoid warning: conversion to 'unsigned long'
     gui.fgcolor = g_new0(GdkColor, 1);
-    /* LINTED: avoid warning: conversion to 'unsigned long' */
+    // LINTED: avoid warning: conversion to 'unsigned long'
     gui.bgcolor = g_new0(GdkColor, 1);
-    /* LINTED: avoid warning: conversion to 'unsigned long' */
+    // LINTED: avoid warning: conversion to 'unsigned long'
     gui.spcolor = g_new0(GdkColor, 1);
 #endif
 
-    /* Initialise atoms */
+    // Initialise atoms
     html_atom = gdk_atom_intern("text/html", FALSE);
     utf8_string_atom = gdk_atom_intern("UTF8_STRING", FALSE);
 
-    /* Set default foreground and background colors. */
+    // Set default foreground and background colors.
     gui.norm_pixel = gui.def_norm_pixel;
     gui.back_pixel = gui.def_back_pixel;
 
@@ -3652,7 +3643,7 @@
     {
 	GtkWidget *plug;
 
-	/* Use GtkSocket from another app. */
+	// Use GtkSocket from another app.
 	plug = gtk_plug_new_for_display(gdk_display_get_default(),
 					gtk_socket_id);
 	if (plug != NULL && gtk_plug_get_socket_window(GTK_PLUG(plug)) != NULL)
@@ -3663,7 +3654,7 @@
 	{
 	    g_warning("Connection to GTK+ socket (ID %u) failed",
 		      (unsigned int)gtk_socket_id);
-	    /* Pretend we never wanted it if it failed (get own window) */
+	    // Pretend we never wanted it if it failed (get own window)
 	    gtk_socket_id = 0;
 	}
     }
@@ -3675,7 +3666,7 @@
 	{
 	    gui.mainwin = gnome_app_new("Vim", NULL);
 # ifdef USE_XSMP
-	    /* Use the GNOME save-yourself functionality now. */
+	    // Use the GNOME save-yourself functionality now.
 	    xsmp_close();
 # endif
 	}
@@ -3686,7 +3677,7 @@
 
     gtk_widget_set_name(gui.mainwin, "vim-main-window");
 
-    /* Create the PangoContext used for drawing all text. */
+    // Create the PangoContext used for drawing all text.
     gui.text_context = gtk_widget_create_pango_context(gui.mainwin);
     pango_context_set_base_dir(gui.text_context, PANGO_DIRECTION_LTR);
 
@@ -3705,7 +3696,7 @@
     gui.accel_group = gtk_accel_group_new();
     gtk_window_add_accel_group(GTK_WINDOW(gui.mainwin), gui.accel_group);
 
-    /* A vertical box holds the menubar, toolbar and main text window. */
+    // A vertical box holds the menubar, toolbar and main text window.
 #if GTK_CHECK_VERSION(3,2,0)
     vbox = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
     gtk_box_set_homogeneous(GTK_BOX(vbox), FALSE);
@@ -3717,7 +3708,7 @@
     if (using_gnome)
     {
 # if defined(FEAT_MENU)
-	/* automagically restore menubar/toolbar placement */
+	// automagically restore menubar/toolbar placement
 	gnome_app_enable_layout_config(GNOME_APP(gui.mainwin), TRUE);
 # endif
 	gnome_app_set_contents(GNOME_APP(gui.mainwin), vbox);
@@ -3736,7 +3727,7 @@
     gui.menubar = gtk_menu_bar_new();
     gtk_widget_set_name(gui.menubar, "vim-menubar");
 
-    /* Avoid that GTK takes <F10> away from us. */
+    // Avoid that GTK takes <F10> away from us.
     {
 	GtkSettings *gtk_settings;
 
@@ -3753,31 +3744,31 @@
 	gnome_app_set_menus(GNOME_APP(gui.mainwin), GTK_MENU_BAR(gui.menubar));
 	dockitem = gnome_app_get_dock_item_by_name(GNOME_APP(gui.mainwin),
 						   GNOME_APP_MENUBAR_NAME);
-	/* We don't want the menu to float. */
+	// We don't want the menu to float.
 	bonobo_dock_item_set_behavior(dockitem,
 		bonobo_dock_item_get_behavior(dockitem)
 				       | BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING);
 	gui.menubar_h = GTK_WIDGET(dockitem);
     }
     else
-# endif	/* FEAT_GUI_GNOME */
+# endif	// FEAT_GUI_GNOME
     {
-	/* Always show the menubar, otherwise <F10> doesn't work.  It may be
-	 * disabled in gui_init() later. */
+	// Always show the menubar, otherwise <F10> doesn't work.  It may be
+	// disabled in gui_init() later.
 	gtk_widget_show(gui.menubar);
 	gtk_box_pack_start(GTK_BOX(vbox), gui.menubar, FALSE, FALSE, 0);
     }
-#endif	/* FEAT_MENU */
+#endif	// FEAT_MENU
 
 #ifdef FEAT_TOOLBAR
     /*
      * Create the toolbar and handle
      */
-    /* some aesthetics on the toolbar */
+    // some aesthetics on the toolbar
 # ifdef USE_GTK3
-    /* TODO: Add GTK+ 3 code here using GtkCssProvider if necessary. */
-    /* N.B.  Since the default value of GtkToolbar::button-relief is
-     * GTK_RELIEF_NONE, there's no need to specify that, probably. */
+    // TODO: Add GTK+ 3 code here using GtkCssProvider if necessary.
+    // N.B.  Since the default value of GtkToolbar::button-relief is
+    // GTK_RELIEF_NONE, there's no need to specify that, probably.
 # else
     gtk_rc_parse_string(
 	    "style \"vim-toolbar-style\" {\n"
@@ -3798,22 +3789,22 @@
 	dockitem = gnome_app_get_dock_item_by_name(GNOME_APP(gui.mainwin),
 						   GNOME_APP_TOOLBAR_NAME);
 	gui.toolbar_h = GTK_WIDGET(dockitem);
-	/* When the toolbar is floating it gets stuck.  So long as that isn't
-	 * fixed let's disallow floating. */
+	// When the toolbar is floating it gets stuck.  So long as that isn't
+	// fixed let's disallow floating.
 	bonobo_dock_item_set_behavior(dockitem,
 		bonobo_dock_item_get_behavior(dockitem)
 				       | BONOBO_DOCK_ITEM_BEH_NEVER_FLOATING);
 	gtk_container_set_border_width(GTK_CONTAINER(gui.toolbar), 0);
     }
     else
-# endif	/* FEAT_GUI_GNOME */
+# endif	// FEAT_GUI_GNOME
     {
 	if (vim_strchr(p_go, GO_TOOLBAR) != NULL
 		&& (toolbar_flags & (TOOLBAR_TEXT | TOOLBAR_ICONS)))
 	    gtk_widget_show(gui.toolbar);
 	gtk_box_pack_start(GTK_BOX(vbox), gui.toolbar, FALSE, FALSE, 0);
     }
-#endif /* FEAT_TOOLBAR */
+#endif // FEAT_TOOLBAR
 
 #ifdef FEAT_GUI_TABLINE
     /*
@@ -3838,7 +3829,7 @@
     {
 	GtkWidget *page, *label, *event_box;
 
-	/* Add the first tab. */
+	// Add the first tab.
 # if GTK_CHECK_VERSION(3,2,0)
 	page = gtk_box_new(GTK_ORIENTATION_VERTICAL, 0);
 	gtk_box_set_homogeneous(GTK_BOX(page), FALSE);
@@ -3869,11 +3860,11 @@
 		     G_CALLBACK(on_tab_reordered), NULL);
 # endif
 
-    /* Create a popup menu for the tab line and connect it. */
+    // Create a popup menu for the tab line and connect it.
     tabline_menu = create_tabline_menu();
     g_signal_connect_swapped(G_OBJECT(gui.tabline), "button-press-event",
 	    G_CALLBACK(on_tabline_menu), G_OBJECT(tabline_menu));
-#endif /* FEAT_GUI_TABLINE */
+#endif // FEAT_GUI_TABLINE
 
     gui.formwin = gtk_form_new();
     gtk_container_set_border_width(GTK_CONTAINER(gui.formwin), 0);
@@ -3890,7 +3881,7 @@
     gui.by_signal = FALSE;
 #endif
 
-    /* Determine which events we will filter. */
+    // Determine which events we will filter.
     gtk_widget_set_events(gui.drawarea,
 			  GDK_EXPOSURE_MASK |
 			  GDK_ENTER_NOTIFY_MASK |
@@ -3908,15 +3899,15 @@
     gtk_widget_show(gui.formwin);
     gtk_box_pack_start(GTK_BOX(vbox), gui.formwin, TRUE, TRUE, 0);
 
-    /* For GtkSockets, key-presses must go to the focus widget (drawarea)
-     * and not the window. */
+    // For GtkSockets, key-presses must go to the focus widget (drawarea)
+    // and not the window.
     g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin)
 					  : G_OBJECT(gui.drawarea),
 		       "key-press-event",
 		       G_CALLBACK(key_press_event), NULL);
 #if defined(FEAT_XIM) || GTK_CHECK_VERSION(3,0,0)
-    /* Also forward key release events for the benefit of GTK+ 2 input
-     * modules.  Try CTRL-SHIFT-xdigits to enter a Unicode code point. */
+    // Also forward key release events for the benefit of GTK+ 2 input
+    // modules.  Try CTRL-SHIFT-xdigits to enter a Unicode code point.
     g_signal_connect((gtk_socket_id == 0) ? G_OBJECT(gui.mainwin)
 					  : G_OBJECT(gui.drawarea),
 		     "key-release-event",
@@ -3948,7 +3939,7 @@
 #endif
 
     if (gtk_socket_id != 0)
-	/* make sure keyboard input can go to the drawarea */
+	// make sure keyboard input can go to the drawarea
 	gtk_widget_set_can_focus(gui.drawarea, TRUE);
 
     /*
@@ -3986,10 +3977,9 @@
 			 G_CALLBACK(enter_notify_event), NULL);
     }
 
-    /* Real windows can get focus ... GtkPlug, being a mere container can't,
-     * only its widgets.  Arguably, this could be common code and we not use
-     * the window focus at all, but let's be safe.
-     */
+    // Real windows can get focus ... GtkPlug, being a mere container can't,
+    // only its widgets.  Arguably, this could be common code and we not use
+    // the window focus at all, but let's be safe.
     if (gtk_socket_id == 0)
     {
 	g_signal_connect(G_OBJECT(gui.mainwin), "focus-out-event",
@@ -4008,7 +3998,7 @@
 			 G_CALLBACK(focus_out_event), NULL);
 	g_signal_connect(G_OBJECT(gui.tabline), "focus-in-event",
 			 G_CALLBACK(focus_in_event), NULL);
-#endif /* FEAT_GUI_TABLINE */
+#endif // FEAT_GUI_TABLINE
     }
 
     g_signal_connect(G_OBJECT(gui.drawarea), "motion-notify-event",
@@ -4033,7 +4023,7 @@
     g_signal_connect(G_OBJECT(gui.drawarea), "selection-get",
 		     G_CALLBACK(selection_get_cb), NULL);
 
-    /* Pretend we don't have input focus, we will get an event if we do. */
+    // Pretend we don't have input focus, we will get an event if we do.
     gui.in_focus = FALSE;
 
     // Handle changes to the "Xft/DPI" setting.
@@ -4086,7 +4076,7 @@
     const GdkRGBA rgba = color_to_rgba(color);
     cairo_set_source_rgba(cr, rgba.red, rgba.green, rgba.blue, rgba.alpha);
 }
-#endif /* GTK_CHECK_VERSION(3,0,0) */
+#endif // GTK_CHECK_VERSION(3,0,0)
 
 /*
  * Called when the foreground or background color has been changed.
@@ -4120,7 +4110,7 @@
 
 	g_free(css);
 	g_object_unref(provider);
-#elif GTK_CHECK_VERSION(3,4,0) /* !GTK_CHECK_VERSION(3,22,2) */
+#elif GTK_CHECK_VERSION(3,4,0) // !GTK_CHECK_VERSION(3,22,2)
 	GdkRGBA rgba;
 
 	rgba = color_to_rgba(gui.back_pixel);
@@ -4135,12 +4125,12 @@
 	    else
 		gdk_window_set_background_rgba(da_win, &rgba);
 	}
-#else /* !GTK_CHECK_VERSION(3,4,0) */
+#else // !GTK_CHECK_VERSION(3,4,0)
 	GdkColor color = { 0, 0, 0, 0 };
 
 	color.pixel = gui.back_pixel;
 	gdk_window_set_background(da_win, &color);
-#endif /* !GTK_CHECK_VERSION(3,22,2) */
+#endif // !GTK_CHECK_VERSION(3,22,2)
     }
 }
 
@@ -4155,35 +4145,34 @@
     int usable_height = event->height;
 
 #if GTK_CHECK_VERSION(3,22,2) && !GTK_CHECK_VERSION(3,22,4)
-    /* As of 3.22.2, GdkWindows have started distributing configure events to
-     * their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0).
-     *
-     * As can be seen from the implementation of move_native_children() and
-     * configure_native_child() in gdkwindow.c, those functions actually
-     * propagate configure events to every child, failing to distinguish
-     * "native" one from non-native one.
-     *
-     * Naturally, configure events propagated to here like that are fallacious
-     * and, as a matter of fact, they trigger a geometric collapse of
-     * gui.formwin.
-     *
-     * To filter out such fallacious events, check if the given event is the
-     * one that was sent out to the right place. Ignore it if not.
-     */
-    /* Follow-up
-     * After a few weeks later, the GdkWindow change mentioned above was
-     * reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155).
-     * The corresponding official release is 3.22.4. */
+    // As of 3.22.2, GdkWindows have started distributing configure events to
+    // their "native" children (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=12579fe71b3b8f79eb9c1b80e429443bcc437dd0).
+    //
+    // As can be seen from the implementation of move_native_children() and
+    // configure_native_child() in gdkwindow.c, those functions actually
+    // propagate configure events to every child, failing to distinguish
+    // "native" one from non-native one.
+    //
+    // Naturally, configure events propagated to here like that are fallacious
+    // and, as a matter of fact, they trigger a geometric collapse of
+    // gui.formwin.
+    //
+    // To filter out such fallacious events, check if the given event is the
+    // one that was sent out to the right place. Ignore it if not.
+    //
+    // Follow-up
+    // After a few weeks later, the GdkWindow change mentioned above was
+    // reverted (https://git.gnome.org/browse/gtk+/commit/?h=gtk-3-22&id=f70039cb9603a02d2369fec4038abf40a1711155).
+    // The corresponding official release is 3.22.4.
     if (event->window != gtk_widget_get_window(gui.formwin))
 	return TRUE;
 #endif
 
-    /* When in a GtkPlug, we can't guarantee valid heights (as a round
-     * no. of char-heights), so we have to manually sanitise them.
-     * Widths seem to sort themselves out, don't ask me why.
-     */
+    // When in a GtkPlug, we can't guarantee valid heights (as a round
+    // no. of char-heights), so we have to manually sanitise them.
+    // Widths seem to sort themselves out, don't ask me why.
     if (gtk_socket_id != 0)
-	usable_height -= (gui.char_height - (gui.char_height/2)); /* sic. */
+	usable_height -= (gui.char_height - (gui.char_height/2)); // sic.
 
     gtk_form_freeze(GTK_FORM(gui.formwin));
     gui_resize_shell(event->width, usable_height);
@@ -4200,13 +4189,13 @@
     static void
 mainwin_destroy_cb(GObject *object UNUSED, gpointer data UNUSED)
 {
-    /* Don't write messages to the GUI anymore */
+    // Don't write messages to the GUI anymore
     full_screen = FALSE;
 
     gui.mainwin  = NULL;
     gui.drawarea = NULL;
 
-    if (!exiting) /* only do anything if the destroy was unexpected */
+    if (!exiting) // only do anything if the destroy was unexpected
     {
 	vim_strncpy(IObuff,
 		(char_u *)_("Vim: Main window unexpectedly destroyed\n"),
@@ -4236,13 +4225,13 @@
 {
     if (init_window_hints_state == 1)
     {
-	/* Safe to use normal hints now */
+	// Safe to use normal hints now
 	init_window_hints_state = 0;
 	update_window_manager_hints(0, 0);
-	return FALSE;   /* stop timer */
+	return FALSE;   // stop timer
     }
 
-    /* Keep on trying */
+    // Keep on trying
     init_window_hints_state = 1;
     return TRUE;
 }
@@ -4271,7 +4260,7 @@
     {
 	char *role;
 
-	/* Invent a unique-enough ID string for the role */
+	// Invent a unique-enough ID string for the role
 	role = g_strdup_printf("vim-%u-%u-%u",
 			       (unsigned)mch_get_pid(),
 			       (unsigned)g_random_int(),
@@ -4284,7 +4273,7 @@
     if (gui_win_x != -1 && gui_win_y != -1)
 	gtk_window_move(GTK_WINDOW(gui.mainwin), gui_win_x, gui_win_y);
 
-    /* Determine user specified geometry, if present. */
+    // Determine user specified geometry, if present.
     if (gui.geom != NULL)
     {
 	int		mask;
@@ -4324,11 +4313,10 @@
 	}
 	VIM_CLEAR(gui.geom);
 
-	/* From now until everyone's stopped trying to set the window hints
-	 * to their correct minimum values, stop them being set as we need
-	 * them to remain at our required size for the parent GtkSocket to
-	 * give us the right initial size.
-	 */
+	// From now until everyone's stopped trying to set the window hints
+	// to their correct minimum values, stop them being set as we need
+	// them to remain at our required size for the parent GtkSocket to
+	// give us the right initial size.
 	if (gtk_socket_id != 0  &&  (mask & WidthValue || mask & HeightValue))
 	{
 	    update_window_manager_hints(pixel_width, pixel_height);
@@ -4339,8 +4327,8 @@
 
     pixel_width = (guint)(gui_get_base_width() + Columns * gui.char_width);
     pixel_height = (guint)(gui_get_base_height() + Rows * gui.char_height);
-    /* For GTK2 changing the size of the form widget doesn't cause window
-     * resizing. */
+    // For GTK2 changing the size of the form widget doesn't cause window
+    // resizing.
     if (gtk_socket_id == 0)
 	gtk_window_resize(GTK_WINDOW(gui.mainwin), pixel_width, pixel_height);
     update_window_manager_hints(0, 0);
@@ -4366,16 +4354,16 @@
 	gui.def_back_pixel = bg_pixel;
     }
 
-    /* Get the colors from the "Normal" and "Menu" group (set in syntax.c or
-     * in a vimrc file) */
+    // Get the colors from the "Normal" and "Menu" group (set in syntax.c or
+    // in a vimrc file)
     set_normal_colors();
 
-    /* Check that none of the colors are the same as the background color */
+    // Check that none of the colors are the same as the background color
     gui_check_colors();
 
-    /* Get the colors for the highlight groups (gui_check_colors() might have
-     * changed them). */
-    highlight_gui_started();	/* re-init colors and fonts */
+    // Get the colors for the highlight groups (gui_check_colors() might have
+    // changed them).
+    highlight_gui_started();	// re-init colors and fonts
 
     g_signal_connect(G_OBJECT(gui.mainwin), "destroy",
 		     G_CALLBACK(mainwin_destroy_cb), NULL);
@@ -4394,15 +4382,15 @@
 		     G_CALLBACK(form_configure_event), NULL);
 
 #ifdef FEAT_DND
-    /* Set up for receiving DND items. */
+    // Set up for receiving DND items.
     gui_gtk_set_dnd_targets();
 
     g_signal_connect(G_OBJECT(gui.drawarea), "drag-data-received",
 		     G_CALLBACK(drag_data_received_cb), NULL);
 #endif
 
-	/* With GTK+ 2, we need to iconify the window before calling show()
-	 * to avoid mapping the window for a short time. */
+	// With GTK+ 2, we need to iconify the window before calling show()
+	// to avoid mapping the window for a short time.
 	if (found_iconic_arg && gtk_socket_id == 0)
 	    gui_mch_iconify();
 
@@ -4510,10 +4498,10 @@
     }
 
     resize_idle_installed = FALSE;
-    return FALSE; /* don't call me again */
+    return FALSE; // don't call me again
 }
 # endif
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
 
 /*
  * Return TRUE if the main window is maximized.
@@ -4561,16 +4549,16 @@
 		      int base_width UNUSED, int base_height UNUSED,
 		      int direction UNUSED)
 {
-    /* give GTK+ a chance to put all widget's into place */
+    // give GTK+ a chance to put all widget's into place
     gui_mch_update();
 
-    /* this will cause the proper resizement to happen too */
+    // this will cause the proper resizement to happen too
     if (gtk_socket_id == 0)
 	update_window_manager_hints(0, 0);
 
-    /* With GTK+ 2, changing the size of the form widget doesn't resize
-     * the window.  So let's do it the other way around and resize the
-     * main window instead. */
+    // With GTK+ 2, changing the size of the form widget doesn't resize
+    // the window.  So let's do it the other way around and resize the
+    // main window instead.
     width  += get_menu_tool_width();
     height += get_menu_tool_height();
 
@@ -4588,7 +4576,7 @@
 	resize_idle_installed = TRUE;
     }
 #  endif
-# endif /* !GTK_CHECK_VERSION(3,0,0) */
+# endif // !GTK_CHECK_VERSION(3,0,0)
     /*
      * Wait until all events are processed to prevent a crash because the
      * real size of the drawing area doesn't reflect Vim's internal ideas.
@@ -4643,8 +4631,8 @@
 
     gui_gtk_get_screen_geom_of_win(gui.mainwin, &x, &y, screen_w, screen_h);
 
-    /* Subtract 'guiheadroom' from the height to allow some room for the
-     * window manager (task list and window title bar). */
+    // Subtract 'guiheadroom' from the height to allow some room for the
+    // window manager (task list and window title bar).
     *screen_h -= p_ghr;
 
     /*
@@ -4669,7 +4657,7 @@
     if (output_conv.vc_type != CONV_NONE)
 	vim_free(title);
 }
-#endif /* FEAT_TITLE */
+#endif // FEAT_TITLE
 
 #if defined(FEAT_MENU) || defined(PROTO)
     void
@@ -4684,7 +4672,7 @@
 # endif
 	widget = gui.menubar;
 
-    /* Do not disable the menu while starting up, otherwise F10 doesn't work. */
+    // Do not disable the menu while starting up, otherwise F10 doesn't work.
     if (!showit != !gtk_widget_get_visible(widget) && !gui.starting)
     {
 	if (showit)
@@ -4695,7 +4683,7 @@
 	update_window_manager_hints(0, 0);
     }
 }
-#endif /* FEAT_MENU */
+#endif // FEAT_MENU
 
 #if defined(FEAT_TOOLBAR) || defined(PROTO)
     void
@@ -4726,7 +4714,7 @@
 	update_window_manager_hints(0, 0);
     }
 }
-#endif /* FEAT_TOOLBAR */
+#endif // FEAT_TOOLBAR
 
 /*
  * Check if a given font is a CJK font. This is done in a very crude manner. It
@@ -4790,11 +4778,11 @@
 
     gui.char_height = (ascent + descent + PANGO_SCALE - 1) / PANGO_SCALE
 								+ p_linespace;
-    /* LINTED: avoid warning: bitwise operation on signed value */
+    // LINTED: avoid warning: bitwise operation on signed value
     gui.char_ascent = PANGO_PIXELS(ascent + p_linespace * PANGO_SCALE / 2);
 
-    /* A not-positive value of char_height may crash Vim.  Only happens
-     * if 'linespace' is negative (which does make sense sometimes). */
+    // A not-positive value of char_height may crash Vim.  Only happens
+    // if 'linespace' is negative (which does make sense sometimes).
     gui.char_ascent = MAX(gui.char_ascent, 0);
     gui.char_height = MAX(gui.char_height, gui.char_ascent + 1);
 
@@ -4802,7 +4790,7 @@
 }
 
 #if GTK_CHECK_VERSION(3,0,0)
-/* Callback function used in gui_mch_font_dialog() */
+// Callback function used in gui_mch_font_dialog()
     static gboolean
 font_filter(const PangoFontFamily *family,
 	    const PangoFontFace   *face UNUSED,
@@ -4847,8 +4835,8 @@
 	else
 	    oldname = oldval;
 
-	/* Annoying bug in GTK (or Pango): if the font name does not include a
-	 * size, zero is used.  Use default point size ten. */
+	// Annoying bug in GTK (or Pango): if the font name does not include a
+	// size, zero is used.  Use default point size ten.
 	if (!vim_isdigit(oldname[STRLEN(oldname) - 1]))
 	{
 	    char_u	*p = vim_strnsave(oldname, STRLEN(oldname) + 3);
@@ -4898,8 +4886,8 @@
 	{
 	    char_u  *p;
 
-	    /* Apparently some font names include a comma, need to escape
-	     * that, because in 'guifont' it separates names. */
+	    // Apparently some font names include a comma, need to escape
+	    // that, because in 'guifont' it separates names.
 	    p = vim_strsave_escaped((char_u *)name, (char_u *)",");
 	    g_free(name);
 	    if (p != NULL && input_conv.vc_type != CONV_NONE)
@@ -4985,8 +4973,8 @@
     gui.ascii_glyphs = NULL;
     gui.ascii_font   = NULL;
 
-    /* For safety, fill in question marks for the control characters.
-     * Put a space between characters to avoid shaping. */
+    // For safety, fill in question marks for the control characters.
+    // Put a space between characters to avoid shaping.
     for (i = 0; i < 128; ++i)
     {
 	if (i >= 32 && i < 127)
@@ -5000,7 +4988,7 @@
     item_list = pango_itemize(gui.text_context, (const char *)ascii_chars,
 			      0, sizeof(ascii_chars), attr_list, NULL);
 
-    if (item_list != NULL && item_list->next == NULL) /* play safe */
+    if (item_list != NULL && item_list->next == NULL) // play safe
     {
 	PangoItem   *item;
 	int	    width;
@@ -5008,7 +4996,7 @@
 	item  = (PangoItem *)item_list->data;
 	width = gui.char_width * PANGO_SCALE;
 
-	/* Remember the shape engine used for ASCII. */
+	// Remember the shape engine used for ASCII.
 	default_shape_engine = item->analysis.shape_engine;
 
 	gui.ascii_font = item->analysis.font;
@@ -5047,8 +5035,8 @@
     PangoLayout		    *layout;
     int			    width;
 
-    /* If font_name is NULL, this means to use the default, which should
-     * be present on all proper Pango/fontconfig installations. */
+    // If font_name is NULL, this means to use the default, which should
+    // be present on all proper Pango/fontconfig installations.
     if (font_name == NULL)
 	font_name = (char_u *)DEFAULT_FONT;
 
@@ -5088,30 +5076,30 @@
     {
 	int cjk_width;
 
-	/* Measure the text extent of U+4E00 and U+4E8C */
+	// Measure the text extent of U+4E00 and U+4E8C
 	pango_layout_set_text(layout, "\344\270\200\344\272\214", -1);
 	pango_layout_get_size(layout, &cjk_width, NULL);
 
-	if (width == cjk_width)  /* Xft not patched */
+	if (width == cjk_width)  // Xft not patched
 	    width /= 2;
     }
     g_object_unref(layout);
 
     gui.char_width = (width / 2 + PANGO_SCALE - 1) / PANGO_SCALE;
 
-    /* A zero width may cause a crash.	Happens for semi-invalid fontsets. */
+    // A zero width may cause a crash.	Happens for semi-invalid fontsets.
     if (gui.char_width <= 0)
 	gui.char_width = 8;
 
     gui_mch_adjust_charheight();
 
-    /* Set the fontname, which will be used for information purposes */
+    // Set the fontname, which will be used for information purposes
     hl_set_font_name(font_name);
 
     get_styled_font_variants();
     ascii_glyph_table_init();
 
-    /* Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'. */
+    // Avoid unnecessary overhead if 'guifontwide' is equal to 'guifont'.
     if (gui.wide_font != NULL
 	&& pango_font_description_equal(gui.norm_font, gui.wide_font))
     {
@@ -5121,13 +5109,13 @@
 
     if (gui_mch_maximized())
     {
-	/* Update lines and columns in accordance with the new font, keep the
-	 * window maximized. */
+	// Update lines and columns in accordance with the new font, keep the
+	// window maximized.
 	gui_mch_newfont();
     }
     else
     {
-	/* Preserve the logical dimensions of the screen. */
+	// Preserve the logical dimensions of the screen.
 	update_window_manager_hints(0, 0);
     }
 
@@ -5143,7 +5131,7 @@
 {
     PangoFontDescription    *font;
 
-    /* can't do this when GUI is not running */
+    // can't do this when GUI is not running
     if (!gui.in_use || name == NULL)
 	return NULL;
 
@@ -5167,7 +5155,7 @@
     {
 	PangoFont *real_font;
 
-	/* pango_context_load_font() bails out if no font size is set */
+	// pango_context_load_font() bails out if no font size is set
 	if (pango_font_description_get_size(font) <= 0)
 	    pango_font_description_set_size(font, 10 * PANGO_SCALE);
 
@@ -5235,7 +5223,7 @@
 {
     guicolor_T color = INVALCOLOR;
 
-    if (!gui.in_use)		/* can't do this when GUI not running */
+    if (!gui.in_use)		// can't do this when GUI not running
 	return color;
 
     if (name != NULL)
@@ -5345,7 +5333,7 @@
 	    if (uc >= 0x80 && utf_char2cells(uc) == 2)
 		start = p;
 	}
-	else if (uc < 0x80 /* optimization shortcut */
+	else if (uc < 0x80 // optimization shortcut
 		 || (utf_char2cells(uc) != 2 && !utf_iscomposing(uc)))
 	{
 	    INSERT_PANGO_ATTR(pango_attr_font_desc_new(gui.wide_font),
@@ -5366,9 +5354,9 @@
 		    int *last_glyph_rbearing)
 {
     char_u  *p;
-    int	    next;	/* glyph start index of next cluster */
-    int	    start, end; /* string segment of current cluster */
-    int	    width;	/* real cluster width in Pango units */
+    int	    next;	// glyph start index of next cluster
+    int	    start, end; // string segment of current cluster
+    int	    width;	// real cluster width in Pango units
     int	    uc;
     int	    cellcount = 0;
 
@@ -5456,8 +5444,8 @@
 		- (gui.char_height - p_linespace) * PANGO_SCALE;
     }
     else
-	/* If the accent width is smaller than the cluster width, position it
-	 * in the middle. */
+	// If the accent width is smaller than the cluster width, position it
+	// in the middle.
 	glyph->geometry.x_offset = -width + MAX(0, width - ink_rect.width) / 2;
 }
 
@@ -5512,7 +5500,7 @@
 		    glyphs);
 #endif
 
-    /* redraw the contents with an offset of 1 to emulate bold */
+    // redraw the contents with an offset of 1 to emulate bold
     if ((flags & DRAW_BOLD) && !gui.font_can_bold)
 #if GTK_CHECK_VERSION(3,0,0)
     {
@@ -5548,7 +5536,7 @@
     static const int	val[8] = {1, 0, 0, 0, 1, 2, 2, 2 };
     int			y = FILL_Y(row + 1) - 1;
 
-    /* Undercurl: draw curl at the bottom of the character cell. */
+    // Undercurl: draw curl at the bottom of the character cell.
     if (flags & DRAW_UNDERC)
     {
 #if GTK_CHECK_VERSION(3,0,0)
@@ -5574,7 +5562,7 @@
 #endif
     }
 
-    /* Draw a strikethrough line */
+    // Draw a strikethrough line
     if (flags & DRAW_STRIKE)
     {
 #if GTK_CHECK_VERSION(3,0,0)
@@ -5595,11 +5583,11 @@
 #endif
     }
 
-    /* Underline: draw a line at the bottom of the character cell. */
+    // Underline: draw a line at the bottom of the character cell.
     if (flags & DRAW_UNDERL)
     {
-	/* When p_linespace is 0, overwrite the bottom row of pixels.
-	 * Otherwise put the line just below the character. */
+	// When p_linespace is 0, overwrite the bottom row of pixels.
+	// Otherwise put the line just below the character.
 	if (p_linespace > 1)
 	    y -= p_linespace - 1;
 #if GTK_CHECK_VERSION(3,0,0)
@@ -5622,11 +5610,11 @@
     int
 gui_gtk2_draw_string(int row, int col, char_u *s, int len, int flags)
 {
-    GdkRectangle	area;		    /* area for clip mask	  */
-    PangoGlyphString	*glyphs;	    /* glyphs of current item	  */
-    int			column_offset = 0;  /* column offset in cells	  */
+    GdkRectangle	area;		    // area for clip mask
+    PangoGlyphString	*glyphs;	    // glyphs of current item
+    int			column_offset = 0;  // column offset in cells
     int			i;
-    char_u		*conv_buf = NULL;   /* result of UTF-8 conversion */
+    char_u		*conv_buf = NULL;   // result of UTF-8 conversion
     char_u		*new_conv_buf;
     int			convlen;
     char_u		*sp, *bp;
@@ -5650,9 +5638,9 @@
 	conv_buf = string_convert(&output_conv, s, &convlen);
 	g_return_val_if_fail(conv_buf != NULL, len);
 
-	/* Correct for differences in char width: some chars are
-	 * double-wide in 'encoding' but single-wide in utf-8.  Add a space to
-	 * compensate for that. */
+	// Correct for differences in char width: some chars are
+	// double-wide in 'encoding' but single-wide in utf-8.  Add a space to
+	// compensate for that.
 	for (sp = s, bp = conv_buf; sp < s + len && bp < conv_buf + convlen; )
 	{
 	    plen = utf_ptr2len(bp);
@@ -5737,26 +5725,26 @@
 	GList		*item_list;
 	int		cluster_width;
 	int		last_glyph_rbearing;
-	int		cells = 0;  /* cells occupied by current cluster */
+	int		cells = 0;  // cells occupied by current cluster
 
-	/* Safety check: pango crashes when invoked with invalid utf-8
-	 * characters. */
+	// Safety check: pango crashes when invoked with invalid utf-8
+	// characters.
 	if (!utf_valid_string(s, s + len))
 	{
 	    column_offset = len;
 	    goto skipitall;
 	}
 
-	/* original width of the current cluster */
+	// original width of the current cluster
 	cluster_width = PANGO_SCALE * gui.char_width;
 
-	/* right bearing of the last non-composing glyph */
+	// right bearing of the last non-composing glyph
 	last_glyph_rbearing = PANGO_SCALE * gui.char_width;
 
 	attr_list = pango_attr_list_new();
 
-	/* If 'guifontwide' is set then use that for double-width characters.
-	 * Otherwise just go with 'guifont' and let Pango do its thing. */
+	// If 'guifontwide' is set then use that for double-width characters.
+	// Otherwise just go with 'guifont' and let Pango do its thing.
 	if (gui.wide_font != NULL)
 	    apply_wide_font_attr(s, len, attr_list);
 
@@ -5778,7 +5766,7 @@
 	while (item_list != NULL)
 	{
 	    PangoItem	*item;
-	    int		item_cells = 0; /* item length in cells */
+	    int		item_cells = 0; // item length in cells
 
 	    item = (PangoItem *)item_list->data;
 	    item_list = g_list_delete_link(item_list, item_list);
@@ -5796,8 +5784,8 @@
 	     */
 	    item->analysis.level = (item->analysis.level + 1) & (~1U);
 
-	    /* HACK: Overrule the shape engine, we don't want shaping to be
-	     * done, because drawing the cursor would change the display. */
+	    // HACK: Overrule the shape engine, we don't want shaping to be
+	    // done, because drawing the cursor would change the display.
 	    item->analysis.shape_engine = default_shape_engine;
 
 #ifdef HAVE_PANGO_SHAPE_FULL
@@ -5841,10 +5829,10 @@
 		    }
 		    else
 		    {
-			/* If there are only combining characters in the
-			 * cluster, we cannot just change the width of the
-			 * previous glyph since there is none.	Therefore
-			 * some guesswork is needed. */
+			// If there are only combining characters in the
+			// cluster, we cannot just change the width of the
+			// previous glyph since there is none.	Therefore
+			// some guesswork is needed.
 			setup_zero_width_cluster(item, glyph, cells,
 						 cluster_width,
 						 last_glyph_rbearing);
@@ -5857,16 +5845,16 @@
 		{
 		    int width;
 
-		    /* There is a previous glyph, so we deal with combining
-		     * characters the canonical way.
-		     * In some circumstances Pango uses a positive x_offset,
-		     * then use the width of the previous glyph for this one
-		     * and set the previous width to zero.
-		     * Otherwise we get a negative x_offset, Pango has already
-		     * positioned the combining char, keep the widths as they
-		     * are.
-		     * For both adjust the x_offset to position the glyph in
-		     * the middle. */
+		    // There is a previous glyph, so we deal with combining
+		    // characters the canonical way.
+		    // In some circumstances Pango uses a positive x_offset,
+		    // then use the width of the previous glyph for this one
+		    // and set the previous width to zero.
+		    // Otherwise we get a negative x_offset, Pango has already
+		    // positioned the combining char, keep the widths as they
+		    // are.
+		    // For both adjust the x_offset to position the glyph in
+		    // the middle.
 		    if (glyph->geometry.x_offset >= 0)
 		    {
 			glyphs->glyphs[i].geometry.width =
@@ -5877,13 +5865,13 @@
 		    glyph->geometry.x_offset +=
 					    MAX(0, width - cluster_width) / 2;
 		}
-		else /* i == 0 "cannot happen" */
+		else // i == 0 "cannot happen"
 		{
 		    glyph->geometry.width = 0;
 		}
 	    }
 
-	    /*** Aaaaand action! ***/
+	    //// Aaaaand action! **
 #if GTK_CHECK_VERSION(3,0,0)
 	    draw_glyph_string(row, col + column_offset, item_cells,
 			      flags, item->analysis.font, glyphs,
@@ -5902,7 +5890,7 @@
     }
 
 skipitall:
-    /* Draw underline and undercurl. */
+    // Draw underline and undercurl.
 #if GTK_CHECK_VERSION(3,0,0)
     draw_under(flags, row, col, column_offset, cr);
 #else
@@ -5990,7 +5978,7 @@
 gui_mch_flash(int msec)
 {
 #if GTK_CHECK_VERSION(3,0,0)
-    /* TODO Replace GdkGC with Cairo */
+    // TODO Replace GdkGC with Cairo
     (void)msec;
 #else
     GdkGCValues	values;
@@ -6023,7 +6011,7 @@
 		       FILL_Y((int)Rows) + gui.border_offset);
 
     gui_mch_flush();
-    ui_delay((long)msec, TRUE);	/* wait so many msec */
+    ui_delay((long)msec, TRUE);	// wait so many msec
 
     gdk_draw_rectangle(gui.drawarea->window, invert_gc,
 		       TRUE,
@@ -6051,7 +6039,7 @@
 # if CAIRO_VERSION >= CAIRO_VERSION_ENCODE(1,9,2)
     cairo_set_operator(cr, CAIRO_OPERATOR_DIFFERENCE);
 # else
-    /* Give an implementation for older cairo versions if necessary. */
+    // Give an implementation for older cairo versions if necessary.
 # endif
     gdk_cairo_rectangle(cr, &rect);
     cairo_fill(cr);
@@ -6173,7 +6161,7 @@
 		gui.fgcolor->alpha);
 	cairo_rectangle(cr,
 # ifdef FEAT_RIGHTLEFT
-	    /* vertical line should be on the right of current point */
+	    // vertical line should be on the right of current point
 	    CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w :
 # endif
 	    FILL_X(gui.col), FILL_Y(gui.row) + gui.char_height - h,
@@ -6181,18 +6169,18 @@
 	cairo_fill(cr);
 	cairo_destroy(cr);
     }
-#else /* !GTK_CHECK_VERSION(3,0,0) */
+#else // !GTK_CHECK_VERSION(3,0,0)
     gdk_gc_set_foreground(gui.text_gc, gui.fgcolor);
     gdk_draw_rectangle(gui.drawarea->window, gui.text_gc,
 	    TRUE,
 # ifdef FEAT_RIGHTLEFT
-	    /* vertical line should be on the right of current point */
+	    // vertical line should be on the right of current point
 	    CURSOR_BAR_RIGHT ? FILL_X(gui.col + 1) - w :
 # endif
 	    FILL_X(gui.col),
 	    FILL_Y(gui.row) + gui.char_height - h,
 	    w, h);
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
 }
 
 
@@ -6214,22 +6202,22 @@
 {
     int *timed_out = (int *) data;
 
-    /* Just inform the caller about the occurrence of it */
+    // Just inform the caller about the occurrence of it
     *timed_out = TRUE;
 
-    return FALSE;		/* don't happen again */
+    return FALSE;		// don't happen again
 }
 
 #ifdef FEAT_JOB_CHANNEL
     static timeout_cb_type
 channel_poll_cb(gpointer data UNUSED)
 {
-    /* Using an event handler for a channel that may be disconnected does
-     * not work, it hangs.  Instead poll for messages. */
+    // Using an event handler for a channel that may be disconnected does
+    // not work, it hangs.  Instead poll for messages.
     channel_handle_events(TRUE);
     parse_queued_messages();
 
-    return TRUE;		/* repeat */
+    return TRUE;		// repeat
 }
 #endif
 
@@ -6264,8 +6252,8 @@
 	timer = 0;
 
 #ifdef FEAT_JOB_CHANNEL
-    /* If there is a channel with the keep_open flag we need to poll for input
-     * on them. */
+    // If there is a channel with the keep_open flag we need to poll for input
+    // on them.
     if (channel_any_keep_open())
 	channel_timer = timeout_add(20, channel_poll_cb, NULL);
 #endif
@@ -6274,7 +6262,7 @@
 
     do
     {
-	/* Stop or start blinking when focus changes */
+	// Stop or start blinking when focus changes
 	if (gui.in_focus != focus)
 	{
 	    if (gui.in_focus)
@@ -6291,7 +6279,7 @@
 	parse_queued_messages();
 # ifdef FEAT_TIMERS
 	if (did_add_timer)
-	    /* Need to recompute the waiting time. */
+	    // Need to recompute the waiting time.
 	    goto theend;
 # endif
 #endif
@@ -6304,7 +6292,7 @@
 	if (!input_available())
 	    g_main_context_iteration(NULL, TRUE);
 
-	/* Got char, return immediately */
+	// Got char, return immediately
 	if (input_available())
 	{
 	    retval = OK;
@@ -6329,12 +6317,12 @@
 }
 
 
-/****************************************************************************
- * Output drawing routines.
- ****************************************************************************/
+/////////////////////////////////////////////////////////////////////////////
+// Output drawing routines.
+//
 
 
-/* Flush any output to the screen */
+// Flush any output to the screen
     void
 gui_mch_flush(void)
 {
@@ -6373,8 +6361,8 @@
 
 #if GTK_CHECK_VERSION(3,0,0)
     {
-	/* Add one pixel to the far right column in case a double-stroked
-	 * bold glyph may sit there. */
+	// Add one pixel to the far right column in case a double-stroked
+	// bold glyph may sit there.
 	const GdkRectangle rect = {
 	    FILL_X(col1), FILL_Y(row1),
 	    (col2 - col1 + 1) * gui.char_width + (col2 == Columns - 1),
@@ -6398,17 +6386,17 @@
 	if (!gui.by_signal)
 	    gdk_window_invalidate_rect(win, &rect, FALSE);
     }
-#else /* !GTK_CHECK_VERSION(3,0,0) */
+#else // !GTK_CHECK_VERSION(3,0,0)
     gdk_gc_set_foreground(gui.text_gc, &color);
 
-    /* Clear one extra pixel at the far right, for when bold characters have
-     * spilled over to the window border. */
+    // Clear one extra pixel at the far right, for when bold characters have
+    // spilled over to the window border.
     gdk_draw_rectangle(gui.drawarea->window, gui.text_gc, TRUE,
 		       FILL_X(col1), FILL_Y(row1),
 		       (col2 - col1 + 1) * gui.char_width
 						      + (col2 == Columns - 1),
 		       (row2 - row1 + 1) * gui.char_height);
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
 }
 
 #if GTK_CHECK_VERSION(3,0,0)
@@ -6459,19 +6447,19 @@
     if (gui.visibility != GDK_VISIBILITY_PARTIAL)
 	return;
 
-    /* Avoid redrawing the cursor while scrolling or it'll end up where
-     * we don't want it to be.	I'm not sure if it's correct to call
-     * gui_dont_update_cursor() at this point but it works as a quick
-     * fix for now. */
+    // Avoid redrawing the cursor while scrolling or it'll end up where
+    // we don't want it to be.	I'm not sure if it's correct to call
+    // gui_dont_update_cursor() at this point but it works as a quick
+    // fix for now.
     gui_dont_update_cursor(TRUE);
 
     do
     {
-	/* Wait to check whether the scroll worked or not. */
+	// Wait to check whether the scroll worked or not.
 	event = gdk_event_get_graphics_expose(gui.drawarea->window);
 
 	if (event == NULL)
-	    break; /* received NoExpose event */
+	    break; // received NoExpose event
 
 	gui_redraw(event->expose.area.x, event->expose.area.y,
 		   event->expose.area.width, event->expose.area.height);
@@ -6479,11 +6467,11 @@
 	expose_count = event->expose.count;
 	gdk_event_free(event);
     }
-    while (expose_count > 0); /* more events follow */
+    while (expose_count > 0); // more events follow
 
     gui_can_update_cursor();
 }
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
 
 #if GTK_CHECK_VERSION(3,0,0)
     static void
@@ -6533,12 +6521,12 @@
 		gui.char_width * ncols + 1,	gui.char_height * nrows);
 #else
     if (gui.visibility == GDK_VISIBILITY_FULLY_OBSCURED)
-	return;			/* Can't see the window */
+	return;			// Can't see the window
 
     gdk_gc_set_foreground(gui.text_gc, gui.fgcolor);
     gdk_gc_set_background(gui.text_gc, gui.bgcolor);
 
-    /* copy one extra pixel, for when bold has spilled over */
+    // copy one extra pixel, for when bold has spilled over
     gdk_window_copy_area(gui.drawarea->window, gui.text_gc,
 	    FILL_X(gui.scroll_region_left), FILL_Y(row),
 	    gui.drawarea->window,
@@ -6552,7 +6540,7 @@
 						       gui.scroll_region_left,
 		    gui.scroll_region_bot, gui.scroll_region_right);
     check_copy_area();
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
 }
 
 /*
@@ -6583,12 +6571,12 @@
 		gui.char_width * ncols + 1,	gui.char_height * nrows);
 #else
     if (gui.visibility == GDK_VISIBILITY_FULLY_OBSCURED)
-	return;			/* Can't see the window */
+	return;			// Can't see the window
 
     gdk_gc_set_foreground(gui.text_gc, gui.fgcolor);
     gdk_gc_set_background(gui.text_gc, gui.bgcolor);
 
-    /* copy one extra pixel, for when bold has spilled over */
+    // copy one extra pixel, for when bold has spilled over
     gdk_window_copy_area(gui.drawarea->window, gui.text_gc,
 	    FILL_X(gui.scroll_region_left), FILL_Y(row + num_lines),
 	    gui.drawarea->window,
@@ -6600,7 +6588,7 @@
     gui_clear_block(row, gui.scroll_region_left,
 				row + num_lines - 1, gui.scroll_region_right);
     check_copy_area();
-#endif /* !GTK_CHECK_VERSION(3,0,0) */
+#endif // !GTK_CHECK_VERSION(3,0,0)
 }
 
 /*
@@ -6624,18 +6612,18 @@
 			      cbd->gtk_sel_atom, target,
 			      (guint32)GDK_CURRENT_TIME);
 
-	/* Hack: Wait up to three seconds for the selection.  A hang was
-	 * noticed here when using the netrw plugin combined with ":gui"
-	 * during the FocusGained event. */
+	// Hack: Wait up to three seconds for the selection.  A hang was
+	// noticed here when using the netrw plugin combined with ":gui"
+	// during the FocusGained event.
 	start = time(NULL);
 	while (received_selection == RS_NONE && time(NULL) < start + 3)
-	    g_main_context_iteration(NULL, TRUE);	/* wait for selection_received_cb */
+	    g_main_context_iteration(NULL, TRUE);	// wait for selection_received_cb
 
 	if (received_selection != RS_FAIL)
 	    return;
     }
 
-    /* Final fallback position - use the X CUT_BUFFER0 store */
+    // Final fallback position - use the X CUT_BUFFER0 store
     yank_cut_buffer0(GDK_WINDOW_XDISPLAY(gtk_widget_get_window(gui.mainwin)),
 	    cbd);
 }
@@ -6699,7 +6687,7 @@
 	grey = TRUE;
 
     gui_mch_menu_hidden(menu, FALSE);
-    /* Be clever about bitfields versus true booleans here! */
+    // Be clever about bitfields versus true booleans here!
     if (!gtk_widget_get_sensitive(menu->id) == !grey)
     {
 	gtk_widget_set_sensitive(menu->id, !grey);
@@ -6740,10 +6728,10 @@
     void
 gui_mch_draw_menubar(void)
 {
-    /* just make sure that the visual changes get effect immediately */
+    // just make sure that the visual changes get effect immediately
     gui_mch_update();
 }
-#endif /* FEAT_MENU */
+#endif // FEAT_MENU
 
 /*
  * Scrollbar stuff.
@@ -6792,9 +6780,9 @@
     void
 gui_mch_setmouse(int x, int y)
 {
-    /* Sorry for the Xlib call, but we can't avoid it, since there is no
-     * internal GDK mechanism present to accomplish this.  (and for good
-     * reason...) */
+    // Sorry for the Xlib call, but we can't avoid it, since there is no
+    // internal GDK mechanism present to accomplish this.  (and for good
+    // reason...)
     XWarpPointer(GDK_WINDOW_XDISPLAY(gtk_widget_get_window(gui.drawarea)),
 		 (Window)0, GDK_WINDOW_XID(gtk_widget_get_window(gui.drawarea)),
 		 0, 0, 0U, 0U, x, y);
@@ -6802,8 +6790,8 @@
 
 
 #ifdef FEAT_MOUSESHAPE
-/* The last set mouse pointer shape is remembered, to be used when it goes
- * from hidden to not hidden. */
+// The last set mouse pointer shape is remembered, to be used when it goes
+// from hidden to not hidden.
 static int last_shape = 0;
 #endif
 
@@ -6835,27 +6823,27 @@
 
 #if defined(FEAT_MOUSESHAPE) || defined(PROTO)
 
-/* Table for shape IDs.  Keep in sync with the mshape_names[] table in
- * misc2.c! */
+// Table for shape IDs.  Keep in sync with the mshape_names[] table in
+// misc2.c!
 static const int mshape_ids[] =
 {
-    GDK_LEFT_PTR,		/* arrow */
-    GDK_CURSOR_IS_PIXMAP,	/* blank */
-    GDK_XTERM,			/* beam */
-    GDK_SB_V_DOUBLE_ARROW,	/* updown */
-    GDK_SIZING,			/* udsizing */
-    GDK_SB_H_DOUBLE_ARROW,	/* leftright */
-    GDK_SIZING,			/* lrsizing */
-    GDK_WATCH,			/* busy */
-    GDK_X_CURSOR,		/* no */
-    GDK_CROSSHAIR,		/* crosshair */
-    GDK_HAND1,			/* hand1 */
-    GDK_HAND2,			/* hand2 */
-    GDK_PENCIL,			/* pencil */
-    GDK_QUESTION_ARROW,		/* question */
-    GDK_RIGHT_PTR,		/* right-arrow */
-    GDK_CENTER_PTR,		/* up-arrow */
-    GDK_LEFT_PTR		/* last one */
+    GDK_LEFT_PTR,		// arrow
+    GDK_CURSOR_IS_PIXMAP,	// blank
+    GDK_XTERM,			// beam
+    GDK_SB_V_DOUBLE_ARROW,	// updown
+    GDK_SIZING,			// udsizing
+    GDK_SB_H_DOUBLE_ARROW,	// leftright
+    GDK_SIZING,			// lrsizing
+    GDK_WATCH,			// busy
+    GDK_X_CURSOR,		// no
+    GDK_CROSSHAIR,		// crosshair
+    GDK_HAND1,			// hand1
+    GDK_HAND2,			// hand2
+    GDK_PENCIL,			// pencil
+    GDK_QUESTION_ARROW,		// question
+    GDK_RIGHT_PTR,		// right-arrow
+    GDK_CENTER_PTR,		// up-arrow
+    GDK_LEFT_PTR		// last one
 };
 
     void
@@ -6878,7 +6866,7 @@
 	    if (id >= GDK_LAST_CURSOR)
 		id = GDK_LEFT_PTR;
 	    else
-		id &= ~1;	/* they are always even (why?) */
+		id &= ~1;	// they are always even (why?)
 	}
 	else if (shape < (int)(sizeof(mshape_ids) / sizeof(int)))
 	    id = mshape_ids[shape];
@@ -6890,13 +6878,13 @@
 # if GTK_CHECK_VERSION(3,0,0)
 	g_object_unref(G_OBJECT(c));
 # else
-	gdk_cursor_destroy(c); /* Unref, actually.  Bloody GTK+ 1. */
+	gdk_cursor_destroy(c); // Unref, actually.  Bloody GTK+ 1.
 # endif
     }
     if (shape != MSHAPE_HIDE)
 	last_shape = shape;
 }
-#endif /* FEAT_MOUSESHAPE */
+#endif // FEAT_MOUSESHAPE
 
 
 #if defined(FEAT_SIGN_ICONS) || defined(PROTO)
@@ -6945,15 +6933,15 @@
 	    int	    w = width;
 	    int	    h = height;
 
-	    /* Keep the original aspect ratio */
+	    // Keep the original aspect ratio
 	    aspect = (double)height / (double)width;
 	    width  = (double)SIGN_WIDTH * SIGN_ASPECT / aspect;
 	    width  = MIN(width, SIGN_WIDTH);
 	    if (((double)(MAX(height, SIGN_HEIGHT)) /
 		 (double)(MIN(height, SIGN_HEIGHT))) < 1.15)
 	    {
-		/* Change the aspect ratio by at most 15% to fill the
-		 * available space completely. */
+		// Change the aspect ratio by at most 15% to fill the
+		// available space completely.
 		height = (double)SIGN_HEIGHT * SIGN_ASPECT / aspect;
 		height = MIN(height, SIGN_HEIGHT);
 	    }
@@ -6962,24 +6950,24 @@
 
 	    if (w == width && h == height)
 	    {
-		/* no change in dimensions; don't decrease reference counter
-		 * (below) */
+		// no change in dimensions; don't decrease reference counter
+		// (below)
 		need_scale = FALSE;
 	    }
 	    else
 	    {
-		/* This doesn't seem to be worth caching, and doing so would
-		 * complicate the code quite a bit. */
+		// This doesn't seem to be worth caching, and doing so would
+		// complicate the code quite a bit.
 		sign = gdk_pixbuf_scale_simple(sign, width, height,
 							 GDK_INTERP_BILINEAR);
 		if (sign == NULL)
-		    return; /* out of memory */
+		    return; // out of memory
 	    }
 	}
 
-	/* The origin is the upper-left corner of the pixmap.  Therefore
-	 * these offset may become negative if the pixmap is smaller than
-	 * the 2x1 cells reserved for the sign icon. */
+	// The origin is the upper-left corner of the pixmap.  Therefore
+	// these offset may become negative if the pixmap is smaller than
+	// the 2x1 cells reserved for the sign icon.
 	xoffset = (width  - SIGN_WIDTH)  / 2;
 	yoffset = (height - SIGN_HEIGHT) / 2;
 
@@ -7027,7 +7015,7 @@
 			FILL_X(col), FILL_Y(col), width, height);
 
 	}
-# else /* !GTK_CHECK_VERSION(3,0,0) */
+# else // !GTK_CHECK_VERSION(3,0,0)
 	gdk_gc_set_foreground(gui.text_gc, gui.bgcolor);
 
 	gdk_draw_rectangle(gui.drawarea->window,
@@ -7050,7 +7038,7 @@
 					    127,
 					    GDK_RGB_DITHER_NORMAL,
 					    0, 0);
-# endif /* !GTK_CHECK_VERSION(3,0,0) */
+# endif // !GTK_CHECK_VERSION(3,0,0)
 	if (need_scale)
 	    g_object_unref(sign);
     }
@@ -7077,8 +7065,8 @@
 
 	if (message != NULL)
 	{
-	    /* The error message is already translated and will be more
-	     * descriptive than anything we could possibly do ourselves. */
+	    // The error message is already translated and will be more
+	    // descriptive than anything we could possibly do ourselves.
 	    semsg("E255: %s", message);
 
 	    if (input_conv.vc_type != CONV_NONE)
@@ -7097,4 +7085,4 @@
 	g_object_unref(sign);
 }
 
-#endif /* FEAT_SIGN_ICONS */
+#endif // FEAT_SIGN_ICONS
diff --git a/src/version.c b/src/version.c
index 4d03ce8..b513b69 100644
--- a/src/version.c
+++ b/src/version.c
@@ -743,6 +743,8 @@
 static int included_patches[] =
 {   /* Add new patch number below this line */
 /**/
+    2380,
+/**/
     2379,
 /**/
     2378,
