32

I'm going through a .vimrc file and there everything is written like this : -

" Better copy & paste
" When you want to paste large blocks of code into vim, press F2 before you
" paste. At the bottom you should see ``-- INSERT (paste) --``.

"" set pastetoggle=<F2>
"" set clipboard=unnamed


" Mouse and backspace
"" set mouse=a  " on OSX press ALT and click
"" set bs=2     " make backspace behave like normal again


" Rebind <Leader> key
" I like to have it here becuase it is easier to reach than the default and
" it is next to ``m`` and ``n`` which I use for navigating between tabs.
"" let mapleader = ","


" Bind nohl
" Removes highlight of your last search
" ``<C>`` stands for ``CTRL`` and therefore ``<C-n>`` stands for ``CTRL+n``
"" noremap <C-n> :nohl<CR>
"" vnoremap <C-n> :nohl<CR>
"" inoremap <C-n> :nohl<CR>


" Quicksave command
"" noremap <C-Z> :update<CR>
"" vnoremap <C-Z> <C-C>:update<CR>
"" inoremap <C-Z> <C-O>:update<CR>

Can someone tell me what is difference between those lines written after " .... and the lines written after ""..... ?

1
  • I have never seen this before. I thought one just wrote the comments, e.g. what I have in my vimrc is a line that says :syntax on and thats it...is that wrong? Nov 10, 2019 at 20:17

1 Answer 1

34

This is the main difference:

" Comments to describe what the line of code below does
"" Actual working code for the .vimrc file but still commented. 

So that when you see double "double quotes" it's commented code, you can uncomment it by removing the double "double quotes", the single "double quotes" mean "I'm just a comment" and are not to be "uncommented", makes sense?. Hope this helps. Do not hesitate to ask if another doubt comes up!

UPDATE 0: In the .vimrc file, line comments are made by adding a double quote " to the left of the text, this means that everything to the right of the " is a comment; multiline comments can't be made in the .vimrc file except adding a " to the beginning of each line, thus resulting in multiple single-line comment unlike C or PHP where you can use these opening-multiline-comment /* and closing-multiline-comment */ . I don't know if it's still out there but there was a plugin called "The NERD plugin" or "The NERD Commenter" in vim. Hope this helps!

UPDATE 1: With regards to the double "double quotes" and single "double quotes", for example the first lines in your .vimrc file:

" Better copy & paste
" When you want to paste large blocks of code into vim, press F2 before you
" paste. At the bottom you should see -- INSERT (paste) --.

"" set pastetoggle=
"" set clipboard=unnamed

Please note at the start of each line there's a bolded double quote like this " this means that every single text character in that line starting immediately to the right of it is a comment.

Now, notice the last two lines where there are double "double quotes" at the beginning of those lines. The first character in the line is a bolded double quote like this " and the second character in the line is an Italic double quote like this ". Again, as explained above, this means that every single text character in that line starting immediately to the right of it is a comment. Now the second "double quote" is part of the comment, you could even add 3 or more double quotes, because when a line has the double quote character everything to the right will be interpreted as a comment. This is just for the programmers or users to detect faster where is the working code and where are the plain comments, a visual reference. Hope this helps. Again, do not hesitate to ask if there's any doubt, Cheers!

5
  • Hello there! Then I suggest that you be a little bit more specific or ask another question. What is it specifically that you'd like to know?
    – zehnner
    Oct 26, 2015 at 8:12
  • you told me the difference between the " and "" with reference of the above .vimrc file . Try to tell the actual difference between them and the different ways to comments the .vimrc file. Oct 26, 2015 at 8:26
  • 1
    @AmitUpadhyay There is only one way to comment in vim, and there is no syntactic difference between " and "" for comments.
    – muru
    Oct 26, 2015 at 10:13
  • I have never seen this before. I thought one just wrote the comments, e.g. what I have in my vimrc is a line that says :syntax on and thats it...is that wrong? Nov 10, 2019 at 20:17
  • I had no idea this was some sort of convention. And if it isn't, it should be. It's a fine idea. Thank you. Next time I open my .vimrc I'm adding an extra quote mark to the commented-out commands.
    – MDeBusk
    Jun 3, 2022 at 1:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .