修剪Xcode中的尾随空格 [英] Trim trailing spaces in Xcode
本文介绍了修剪Xcode中的尾随空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在保存文件时是否有一种方法可以强制Xcode修剪尾随空格?
Is there a way to force Xcode to trim trailing whitespaces when I save file?
如果这很重要,我正在使用3.1.3版。
I'm using version 3.1.3 if that matters.
推荐答案
您可以创建脚本并将其绑定到键盘快捷键:
You can create a script and bind it to a keyboard shortcut:
- 选择脚本菜单>编辑用户脚本...
- 按+按钮并选择 New Shell脚本
- 给它一个类似于 Strip Trailing Spaces的名称,并给它一个类似于⌃⇧R的快捷方式。
- 将Input设置为 Selection,然后输出到替换选择
- Select Scripts Menu > Edit User Scripts...
- Press the + button and select New Shell Script
- Give it a name like "Strip Trailing Spaces", and give it a shortcut like ⌃⇧R.
- Set Input to "Selection" and Output to "Replace Selection"
然后输入以下脚本:
#!/usr/bin/perl
while (<>) {
s/\s+$//;
print "$_\n";
}
这篇关于修剪Xcode中的尾随空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文