commentstring option is used by Vim to handle comments that span the entire line. This option can be set in your Vimrc for a specific filetype or globally for all files.
To set a commentstring globally for all undetected filetypes, for example the hash symbol:
setglobal commentstring=# %s
To set a commentstring specifically for a filetype, say for C++ files:
autocmd FileType cpp setlocal commentstring=// %s
The above setting is actually useful because Vim does not use this style of comments by default for C++.
For more info, see How Vim handles comments.
Tried with: Vim 7.4 and Ubuntu 14.04