在崇高的文本2中缩进代码?

时间:2021-10-09 08:46:55

In Visual Studio I can press Ctrl+K+D to indent everything so the code is structured nicely and readable. Is there a shortcut in Sublime 2 to do the same?

在Visual Studio中,我可以按Ctrl+K+D对所有内容进行缩进,这样代码就可以很好地进行结构化和可读性。在《崇高2》中是否有一条捷径去做同样的事?

17 个解决方案

#1


797  

You can find it in EditLineReindent, but it does not have a shortcut by default. You can add a shortcut by going to the menu PreferencesKeybindingsUser, then add there:

你可以找到它在编辑→线→Reindent,但它没有默认快捷方式。您可以通过将菜单添加一个快捷方式偏好→键→用户,然后添加:

{ "keys": ["f12"], "command": "reindent", "args": {"single_line": false} }  

(example of using the F12 key for that functionality)

(使用F12键实现该功能)

The config files use JSON-syntax, so these curly braces have to be placed comma-separated in the square-brackets that are there by default. If you don't have any other key-bindings already, then your whole KeybindingsUser file would look like this, of course:

配置文件使用json语法,所以这些花括号必须放在默认的方括号中,中间用逗号分隔。如果你没有任何其他的键绑定,然后你的整个快捷键→用户文件是这样的,当然,

[
    { "keys": ["f12"], "command": "reindent", "args": {"single_line": false}}
]

#2


273  

The reindent command only works on the currently selected lines unless the "single_line" argument is set to false.

除非将“single_line”参数设置为false,否则reindent命令只对当前选定的行有效。

{ "keys": ["f12"], "command": "reindent", "args": {"single_line": false} }

Now, pressing f12 will reindent the entire document.

现在,按f12将使整个文档恢复。

#3


30  

No one seems to love mac re-indentation, So here How I do it:

似乎没有人喜欢mac reindentation,所以我做了如下:

[
   { "keys": ["command+shift+i"], "command": "reindent"}
]

In Preferences > Key Binding - User

在首选项中>键绑定-用户

One more extra tip: add

还有一个额外的建议:添加。

{ "keys": ["command+0"], "command": "focus_side_bar" }

to have sidebar file tree view navigation using keyboard.

要使用键盘进行侧边栏文件树视图导航。

Note: Add , at the end of each {}, if you have more than one {} set of objects

注意:如果您有多个{}对象集,请在每个{}末尾添加

#4


26  

There is no default shortcut for reindenting a file. However you can create one by following eznme's answer above.

没有重新插入文件的默认快捷方式。但是你可以按照上面eznme的回答创建一个。

You can also use the Command Palette by pressing:

你也可以使用命令调色板按:

  1. Control+Shift+P (or +Shift+P on a Mac)
  2. 控制+ Shift + P(或⌘+ Shift + P Mac)
  3. Type the first few characters of Reindent e.g: rein
  4. 输入Reindent e的前几个字符。旅客:控制
  5. Press Enter to run the command
    (The first command at the top should now show Indentation: Reindent Lines)
  6. 按Enter以运行命令(顶部的第一个命令现在应该显示缩进:恢复行)

#5


19  

For those interested it is easy to change but for a lover of Netbeans and the auto-format you can change the key binding from F12 to ctrl+shift+F to use your beloved key binding. Sad part is that you have to select all to format the entire file. Netbeans still has the upper hand on that. If anyone knows how to overcome that limitation I'm all ears. Otherwise happy reindenting (auto-formating).

对于那些感兴趣的人来说,很容易改变,但是对于Netbeans和自动格式的爱好者来说,您可以将键绑定从F12更改为ctrl+shift+F,以使用您钟爱的密钥绑定。遗憾的是,您必须选择所有格式来格式化整个文件。Netbeans在这方面仍占上风。如果有人知道如何克服这个限制,我洗耳恭听。否则快乐reindenting(自动格式化)。

#6


16  

To indent with the same keys like Visual Studio Ctrl+K+D (I am a Visual Studio user so I am used to this combination) I suggest:

使用Visual Studio Ctrl+K+D(我是Visual Studio用户,所以我习惯了这种组合)等相同的键进行缩进,我建议:

[
{ "keys": ["ctrl+k", "ctrl+d"], "command": "reindent", "args": {"single_line": false} }
]

Write this on Preferences>Key Bindings - User

在首选项>键绑定-用户上写入

#7


5  

It is very simple. Just go to Edit=>Line=>Reindent

它是非常简单的。去编辑= > = > Reindent行

#8


5  

Netbeans like Shortcut Key

Go to Preferences > Key Bindings > User and add the code below:

转到Preferences >键绑定>用户,并添加以下代码:

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

Usage

使用

Ctrl + Shift + F

Ctrl + Shift + F

#9


4  

code formatter.

simple to use.

易于使用。


1.Install

1.安装


2.press ctrl + alt + f (default)

2。按ctrl + alt + f(默认)


Thats it.

这是它。

#10


3  

Select all code that you intend to indent, then hit Ctrl + ] in Sublime text to indent.

选择您想要缩进的所有代码,然后在崇高的文本中按Ctrl +]以缩进。

For Mac users, use command + ] to indent, and command + [ to un-indent.

对于Mac用户,使用命令+)缩进,命令+[对不缩进。

#11


2  

Beside of the inbuilt 'reindent' function, you can also install other plugins, such as SublimeAStyleFormatter and CodeFormatter. These plugins are better for their specify language.

除了内置的“reindent”函数之外,您还可以安装其他插件,比如SublimeAStyleFormatter和CodeFormatter。这些插件更适合它们的指定语言。

#12


2  

Just in case this stop working for anyone like me, in OS X, the command key is identified as superso it should be able to do something like this:

在OS X中,为了防止这个停止工作,在OS X中,命令键被标识为superso它应该能够这样做:

[
    {
    "keys": ["super+i"], 
    "command": "reindent", 
    "args": {
        "single_line": 
        false}
    } 
]

in this case using command+i is going to indent your whole code (eclipse like :) )

在这种情况下,使用命令+i将对整个代码进行缩进(eclipse like:)

#13


1  

I used to use Alt + Shift + F in NetBeans, I checked and there isn't any collision in the default keymap array of sublime, so I added it to my sublime and I'm using it without any problem.

我曾经在NetBeans中使用Alt + Shift + F,我检查过,在sublime的默认keymap数组中没有任何冲突,所以我将它添加到sublime中,我可以毫无问题地使用它。

#14


0  

For Auto-Formatting in Sublime Text 2: Install Package: Tag from Command Palette, then go to Edit -> Tag -> Auto-Format Tags on Document

为在崇高的文本2:安装包:标签从命令调色板,然后进入编辑->标签->自动格式标签上的文件

#15


0  

This is my configuration for sublime-keymap

这是我对sublime-keymap的配置

[ { "keys": [",+=+="], "command": "reindent", "args": { "single_line": false } } ]

[{“钥匙”:“+ = + =”,“命令”:“reindent”,“参数”:{“single_line”:假} })

For vim people, just use ,== to reindent the whole file.

对于vim人员,只需使用==来重新保存整个文件。

#16


0  

First open the sublime text.
than open preferences.
than open Key Bindings -User.
than put the below code

首先打开崇高的文本。比公开的偏好。比打开键绑定-用户。比放下面的代码

[{"keys": ["ctrl+shift+c"], "command": "reindent"},]

[{“钥匙”:“ctrl + shift + c”,“命令”:“reindent”},)

I use Ctrl+Shift+C and you also use other short cut key.

我用Ctrl+Shift+C,你也用其他的快捷键。

#17


0  

For those who like the default key binding for IntelJ IDEA, select Preferences > Settings - User:

对于那些喜欢IntelJ IDEA默认键绑定的用户,请选择Preferences >设置- User:

在崇高的文本2中缩进代码?

And paste in the following to have the command + shift + l shortcut for auto indent:

并粘贴以下命令+ shift + l快捷键进行自动缩进:

[
   { "keys": ["command+shift+l"], "command": "reindent"}
]

#1


797  

You can find it in EditLineReindent, but it does not have a shortcut by default. You can add a shortcut by going to the menu PreferencesKeybindingsUser, then add there:

你可以找到它在编辑→线→Reindent,但它没有默认快捷方式。您可以通过将菜单添加一个快捷方式偏好→键→用户,然后添加:

{ "keys": ["f12"], "command": "reindent", "args": {"single_line": false} }  

(example of using the F12 key for that functionality)

(使用F12键实现该功能)

The config files use JSON-syntax, so these curly braces have to be placed comma-separated in the square-brackets that are there by default. If you don't have any other key-bindings already, then your whole KeybindingsUser file would look like this, of course:

配置文件使用json语法,所以这些花括号必须放在默认的方括号中,中间用逗号分隔。如果你没有任何其他的键绑定,然后你的整个快捷键→用户文件是这样的,当然,

[
    { "keys": ["f12"], "command": "reindent", "args": {"single_line": false}}
]

#2


273  

The reindent command only works on the currently selected lines unless the "single_line" argument is set to false.

除非将“single_line”参数设置为false,否则reindent命令只对当前选定的行有效。

{ "keys": ["f12"], "command": "reindent", "args": {"single_line": false} }

Now, pressing f12 will reindent the entire document.

现在,按f12将使整个文档恢复。

#3


30  

No one seems to love mac re-indentation, So here How I do it:

似乎没有人喜欢mac reindentation,所以我做了如下:

[
   { "keys": ["command+shift+i"], "command": "reindent"}
]

In Preferences > Key Binding - User

在首选项中>键绑定-用户

One more extra tip: add

还有一个额外的建议:添加。

{ "keys": ["command+0"], "command": "focus_side_bar" }

to have sidebar file tree view navigation using keyboard.

要使用键盘进行侧边栏文件树视图导航。

Note: Add , at the end of each {}, if you have more than one {} set of objects

注意:如果您有多个{}对象集,请在每个{}末尾添加

#4


26  

There is no default shortcut for reindenting a file. However you can create one by following eznme's answer above.

没有重新插入文件的默认快捷方式。但是你可以按照上面eznme的回答创建一个。

You can also use the Command Palette by pressing:

你也可以使用命令调色板按:

  1. Control+Shift+P (or +Shift+P on a Mac)
  2. 控制+ Shift + P(或⌘+ Shift + P Mac)
  3. Type the first few characters of Reindent e.g: rein
  4. 输入Reindent e的前几个字符。旅客:控制
  5. Press Enter to run the command
    (The first command at the top should now show Indentation: Reindent Lines)
  6. 按Enter以运行命令(顶部的第一个命令现在应该显示缩进:恢复行)

#5


19  

For those interested it is easy to change but for a lover of Netbeans and the auto-format you can change the key binding from F12 to ctrl+shift+F to use your beloved key binding. Sad part is that you have to select all to format the entire file. Netbeans still has the upper hand on that. If anyone knows how to overcome that limitation I'm all ears. Otherwise happy reindenting (auto-formating).

对于那些感兴趣的人来说,很容易改变,但是对于Netbeans和自动格式的爱好者来说,您可以将键绑定从F12更改为ctrl+shift+F,以使用您钟爱的密钥绑定。遗憾的是,您必须选择所有格式来格式化整个文件。Netbeans在这方面仍占上风。如果有人知道如何克服这个限制,我洗耳恭听。否则快乐reindenting(自动格式化)。

#6


16  

To indent with the same keys like Visual Studio Ctrl+K+D (I am a Visual Studio user so I am used to this combination) I suggest:

使用Visual Studio Ctrl+K+D(我是Visual Studio用户,所以我习惯了这种组合)等相同的键进行缩进,我建议:

[
{ "keys": ["ctrl+k", "ctrl+d"], "command": "reindent", "args": {"single_line": false} }
]

Write this on Preferences>Key Bindings - User

在首选项>键绑定-用户上写入

#7


5  

It is very simple. Just go to Edit=>Line=>Reindent

它是非常简单的。去编辑= > = > Reindent行

#8


5  

Netbeans like Shortcut Key

Go to Preferences > Key Bindings > User and add the code below:

转到Preferences >键绑定>用户,并添加以下代码:

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

Usage

使用

Ctrl + Shift + F

Ctrl + Shift + F

#9


4  

code formatter.

simple to use.

易于使用。


1.Install

1.安装


2.press ctrl + alt + f (default)

2。按ctrl + alt + f(默认)


Thats it.

这是它。

#10


3  

Select all code that you intend to indent, then hit Ctrl + ] in Sublime text to indent.

选择您想要缩进的所有代码,然后在崇高的文本中按Ctrl +]以缩进。

For Mac users, use command + ] to indent, and command + [ to un-indent.

对于Mac用户,使用命令+)缩进,命令+[对不缩进。

#11


2  

Beside of the inbuilt 'reindent' function, you can also install other plugins, such as SublimeAStyleFormatter and CodeFormatter. These plugins are better for their specify language.

除了内置的“reindent”函数之外,您还可以安装其他插件,比如SublimeAStyleFormatter和CodeFormatter。这些插件更适合它们的指定语言。

#12


2  

Just in case this stop working for anyone like me, in OS X, the command key is identified as superso it should be able to do something like this:

在OS X中,为了防止这个停止工作,在OS X中,命令键被标识为superso它应该能够这样做:

[
    {
    "keys": ["super+i"], 
    "command": "reindent", 
    "args": {
        "single_line": 
        false}
    } 
]

in this case using command+i is going to indent your whole code (eclipse like :) )

在这种情况下,使用命令+i将对整个代码进行缩进(eclipse like:)

#13


1  

I used to use Alt + Shift + F in NetBeans, I checked and there isn't any collision in the default keymap array of sublime, so I added it to my sublime and I'm using it without any problem.

我曾经在NetBeans中使用Alt + Shift + F,我检查过,在sublime的默认keymap数组中没有任何冲突,所以我将它添加到sublime中,我可以毫无问题地使用它。

#14


0  

For Auto-Formatting in Sublime Text 2: Install Package: Tag from Command Palette, then go to Edit -> Tag -> Auto-Format Tags on Document

为在崇高的文本2:安装包:标签从命令调色板,然后进入编辑->标签->自动格式标签上的文件

#15


0  

This is my configuration for sublime-keymap

这是我对sublime-keymap的配置

[ { "keys": [",+=+="], "command": "reindent", "args": { "single_line": false } } ]

[{“钥匙”:“+ = + =”,“命令”:“reindent”,“参数”:{“single_line”:假} })

For vim people, just use ,== to reindent the whole file.

对于vim人员,只需使用==来重新保存整个文件。

#16


0  

First open the sublime text.
than open preferences.
than open Key Bindings -User.
than put the below code

首先打开崇高的文本。比公开的偏好。比打开键绑定-用户。比放下面的代码

[{"keys": ["ctrl+shift+c"], "command": "reindent"},]

[{“钥匙”:“ctrl + shift + c”,“命令”:“reindent”},)

I use Ctrl+Shift+C and you also use other short cut key.

我用Ctrl+Shift+C,你也用其他的快捷键。

#17


0  

For those who like the default key binding for IntelJ IDEA, select Preferences > Settings - User:

对于那些喜欢IntelJ IDEA默认键绑定的用户,请选择Preferences >设置- User:

在崇高的文本2中缩进代码?

And paste in the following to have the command + shift + l shortcut for auto indent:

并粘贴以下命令+ shift + l快捷键进行自动缩进:

[
   { "keys": ["command+shift+l"], "command": "reindent"}
]