Is there a keyboard shortcut to delete blank lines in C # code files (.cs)?
Similar to Ctrl + K , D , which formats the entire .cs file.
Or is there a workaround?
Use the Find and Replace dialog ( Ctrl + H ). Search
\n\n
and replace with
\n
using regular expressions (expand the "Search Options" section to include).
If you want to remove lines containing only spaces, you can try searching
\n\s*\n+
CodeMaid has a parameter that automatically deletes empty lines (if you save the file, I think) in accordance with some custom rules. I think this makes the files pretty neat.
I do not think so. You can use a separate refactoring add-on for automation, for example ReSharper .
In the Visual Studio options in the Text Editor β General section, there is the option "Apply the" Cut "and" Copy "commands to empty lines when there is no choice." If you check this, Ctrl + X will delete the empty line.