Converting spaces to tabs in multiple files Sublime Text 2

隐身守侯 提交于 2021-02-06 09:56:30

问题


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

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.


回答1:


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

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.

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



来源:https://stackoverflow.com/questions/20675237/converting-spaces-to-tabs-in-multiple-files-sublime-text-2

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