Is there any keyboard shortcut to remove empty lines in C# code files (.cs)?
Similar to Ctrl + K , D which formats the whole .cs file.
Or is there a workaround?
Use the Find and Replace dialog (Ctrl + H). Search for
\n\n
and replace with
\n
using regular expressions (expand the Find Options section to enable).
If you want to remove lines containing nothing but whitespace you could try searching for
\n\s*\n+
CodeMaid has a setting that automatically removes empty lines (when you save the file, I think) according to some configurable rules. I think it makes the files quite neat.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With