I am playing around with asm, which uses ATT syntax. For the filetype asm, vim is using the comment char ;, though it should be #. How/where can I change the comment char per file type? Note that I am currently using NERDCommenter. I am looking to add something like:

autocmd Filetype asm comment='#'

Note, it looks like this is defined here in NERD_commenter.vim:

let s:delimiterMap = {
    \ 'asm': { 'left': ';', 'leftAlt': '#' },

But I'm not sure how/where to 'overwrite' this (other than modifying this code directly, which I don't want to do).

  • I think you're looking for the comments setting? I don't quite know how this all works, so you'll have to wait for someone else to give an answer, or you can try reading up on :help comments and see how far that gets you :-) Commented Aug 1, 2020 at 22:11

1 Answer 1


As Martin suggested, the definition of comment continuation characters happens in 'comments' (and 'commentstring') settings. Comment related plugins like NerdCommenter/EnhancedCommentify/tComment(?)/... have their own way to define which sequences shall be used to comment existing blocks -- some of them use what is defined in &comments or &commentstring.

The easy solution would be to add a ~/.vim/after/ftplugin/asm/att.vim file in your configuration that expands default ASM settings with

setlocal comments+=:#

This way, ;, // and /*...*/ are still kept as comments.

If more differences exist, you may want instead to exploit vim default detection of asm flavour (see $VIMRUNTIME/autoload/dist/ft.vim) by adding # asmsyntax=attasm in your files, and a ~/.vim/ftplugin/attasm.vim that contains exactly what you want, and a syntax file that loads default asm syntax highlighting file (w/ :runtime syntax/asm.vim).

You may want to read :h asm.vim.

Note, I wonder whether the fact that # isn't configured as a continuation character is because it may have side effects with GAS preprocessor (according to this Q/A), and thus seen as a bad practice.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.