vimrc file comments - double-quotes vs two double-quotes

29,070

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!

Share:
29,070

Related videos on Youtube

Amit Upadhyay
Author by

Amit Upadhyay

I welcome you to this page and I have got a message for you: "The only way out is through." I love to play with technologies & try to learn new things every day. I'm good with programming languages & their compilers (Go, Java, Python, C, C++, JavaScript, C#). I am also good with Data Structure & Algorithms and use them to solve problems optimally. Got decent experience in software developments too. I mostly focus on solving problems with the best possible technology present, optimizing modules involved in the application, writing a good design. I love building things, making them scalable. I have made some software products which are present in the market. To know more about me and my projects please visit http://binomial.me I've worked heavily with Android during my school time, built few apps which are available in Playstore also worked as a freelancer, developed an android application for a company. IDEs I prefer using: vim & Intellij. I contribute back to the programmers' community here on Binomial.me and of course on StackOverflow Feel free to contact me at [email protected], [email protected]

Updated on September 18, 2022

Comments

  • Amit Upadhyay
    Amit Upadhyay over 1 year

    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 ""..... ?

    • Admin
      Admin over 4 years
      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?
  • Amit Upadhyay
    Amit Upadhyay over 8 years
    hello, this i also know.. and anyone can figure out... you didn't get the question
  • zehnner
    zehnner over 8 years
    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?
  • Amit Upadhyay
    Amit Upadhyay over 8 years
    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.
  • muru
    muru over 8 years
    @AmitUpadhyay There is only one way to comment in vim, and there is no syntactic difference between " and "" for comments.
  • Charlie Parker
    Charlie Parker over 4 years
    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?
  • Admin
    Admin almost 2 years
    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.