Autoindent on Sublime Text

主宰稳场 提交于 2019-12-03 11:14:39

问题


Are there any command/shortcut to auto-indent all my code on the page at once on Sublime Text 3?

e.g: On NetBeans I can do this with Alt+Shift+F.


回答1:


That's quite simple in Sublime. Just Ctrl+Shift+P (to open tools pallet), type reindent, and pick Indentation: Reindent Lines. It should reindent all the file you are in, just remember to save before running the command, or it may not appear.




回答2:


Auto-indenting on Sublime Text 3 - "Key Bindings"

Just add this binding to your "Key Bindings - User" file:

Preferences > Key Bindings - users

{"keys": ["alt+shift+f"], "command": "reindent", "args": {"single_line": false}}

And adding this code between the square brackets.

Now you can use Alt + Shift + f as your auto-indent shortcut

You can also use the "reindent" feature through the command palette. Ctrl + Shift + P


Ressources:

Auto-indenting on Sublime Text 3 by Osvaldo Zonetti

Create a Keybinding by Joe Lloyd




回答3:


You can use one of many plugins which do the thing you need, for example, the one I am using:

  • https://github.com/akalongman/sublimetext-codeformatter


来源:https://stackoverflow.com/questions/44803547/autoindent-on-sublime-text

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