Keyboard shortcut to remove empty lines in a C# code file

*爱你&永不变心* 提交于 2019-12-01 16:42:36
Ed Guiness

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.

James King

In the Visual Studio options, under Text Editor -> General, there's an option "Apply Cut and Copy commands to blank lines when there is no selection". If you check this, Ctrl + X will remove a blank line.

Madhur Ahuja

I don't think there is any. You can use a separate refactoring add-in to automate this, such as ReSharper.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!