preservim / nerdcommenter

Vim plugin for intensely nerdy commenting powers
Creative Commons Zero v1.0 Universal
4.99k stars 446 forks source link

uncaught error when using with readonly file #171

Open ghost opened 9 years ago

ghost commented 9 years ago

When commenting or uncommenting a read-only file I get the error:

Error detected while processing function NERDComment..<SNR>50_InvertComment..<SNR>50_UncommentLines..<SNR>50_UncommentLinesNormal:
line    4:W10: Warning: Changing a readonly file
Press ENTER or type command to continue

The error should be caught and a cleaner message displayed, like the standard one Vim issues:

-- INSERT -- W10: Warning: Changing a readonly file
MandrakeQ commented 9 years ago

You can add "silent" to all the setline calls to completely silence the error/warning messages. I don't know of a way to hide just the errors though and still echo warnings.