简体   繁体   English

有没有办法让notepad ++用2替换4个空格?

[英]Is there a way to have notepad++ replace 4 spaces with 2?

I'm looking through the menu options and don't see any. 我正在浏览菜单选项,但没有看到任何内容。

I'm thinking about just doing a search for 4 lines and replacing with 2. 我正在考虑只搜索4行并替换为2。

For some reason I don't trust this completely. 由于某种原因,我不完全相信这一点。

One option is to use Find and Replace (with Regex). 一种选择是使用查找和替换(使用正则表达式)。 This exactly replaces the beginning of a line with 4 spaces with 2 spaces. 正好用4个空格和2个空格替换了一行的开头。

Started with: 开始于:

记事本++-开始

Find and Replace: 查找和替换:

记事本++-查找和替换

Results: 结果:

记事本++-结束

You may use the following 您可以使用以下内容

  1. Set the tabsize to 4 spaces (Settings -> Preferences -> Lanuage Menu/TabSettings) 将制表符大小设置为4个空格(“设置”->“首选项”->“语言菜单/选项卡设置”)
  2. Convert your spaces to tabs (Edit->Blank Operations->Spaces to TAB) 将您的空间转换为选项卡(“编辑”->“空白操作”->“将空间转换为TAB”)
  3. Set the tabsize to 2 将制表符大小设置为2
  4. Convert your tabs to spaces (Edit->Blank Operations->TAB to Spaces) 将选项卡转换为空格(编辑->空白操作-> TAB转换为空格)

BEWARE: This will mess up your file, if you currently also use tabs and not only spaces! 注意:如果您当前还使用制表符,而不仅是空格,那么这会弄乱您的文件!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM