将空格转换为多个文件中的制表符Sublime Text 2 [英] Converting spaces to tabs in multiple files Sublime Text 2

查看:87
本文介绍了将空格转换为多个文件中的制表符Sublime Text 2的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有什么方法可以将所有空格转换为制表符,而不是逐个文件地转换吗?

Is there any way to convert all spaces to tabs, not file by file?

如果我打开文件并通过 View =>缩进=>将缩进转换为制表符,它只会更改此文件.我想将缩进转换为整个项目中的选项卡.

If I open a file and go through View => Indentation => Convert Indentation to Tabs, it only changes this file. I want to convert indentations to tabs in a whole project.

推荐答案

使用搜索并替换为多个文件以将 n 个空格转换为所选文件中的标签.

Use search and replace in multiple files to convert n spaces to tabs in select files.

首先在文件面板中打开查找, cmd + shift + f ,默认情况下可查找并替换多个文件.接下来定义一个正则表达式以将空格匹配为制表符,例如 {4} (确保在面板中设置了 Regular Expressions )为4个空格,并替换为 \ t在所需文件中.将 {4} 更改为用于缩进的空格.

First open find in files panel, cmd + shift + f, by default to find and replace in multiple files. Next define a regular expression to match spaces as tabs eg {4} (make sure you set Regular Expressions in the panel) for 4 spaces and replace with \t in desired files. Change {4} to however many spaces are being used for indentation.

如注释中所述,在行首匹配空格,您可以使用regexp ^({4})+

As mentioned in comments to match spaces at the start of a line you can use the regexp ^( {4})+

这篇关于将空格转换为多个文件中的制表符Sublime Text 2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆