Commenting c++ codes in Vim
问题 I want to map \c to comment the current line in vim (add '// ' to before the first non-blank to the line) and \d to delete the '// ' at the beginning of line(uncomment). I've added these two lines in my vimrc: imap \c <Esc>:s/^/\/\/ <CR>j$a imap \d <Esc>:s/^\/\/ /<CR>j$a but when I call this in this line: for (int i = 0; i < n; i++) then it is converted to: // for (int i = 0; i < n; i++) but I want to convert it to: // for (int i = 0; i < n; i++) one of the reasons I want this is that when I