标签: auto-indent

如何将JavaScript格式应用于.json文件?

Eclipse中的Ctrl+ Shift+ F热键可以格式化文件.它不适用于.json文件.如何使它工作?

eclipse formatting json indentation auto-indent

17
推荐指数
2
解决办法
2万
查看次数

是否可以仅自动缩进Visual Studio Code上的当前行?

在Atom(以及许多其他编辑器)上,有一个auto-indent命令允许我们自动缩进光标所在的行.Visual Studio代码中是否有等价物?

我知道Visual Studio Code上有格式化程序操作,但从我所看到的,它只能用于:

  • 格式化选择(ctrl-K ctrl-F)
  • 格式化孔文档(ctrl + shift + I)

我希望能够格式化光标所在的行,而无需重新格式化整个文档,也无需进行选择.

基本上,我想配置[TAB]键,这样当我按下[TAB]时,它只会自动缩进光标所在的行:

  • 如果没有任何内容写在该行上,它只是将光标放在正确的位置,这样当我开始写入时,代码正确缩进.
  • 如果已经在线上写了一些东西,它会对该线进行音频缩进

可能吗 ?

auto-indent visual-studio-code

17
推荐指数
1
解决办法
1289
查看次数

使用Xcode缩进Objective-C文字

Xcode认为这个:

NSArray *persons = @[
    @{
        @"name": @"Bob",
        @"pet": @"cat"
    },
    @{
        @"name": @"Alice",
        @"pet": @"dog"
    }
];
Run Code Online (Sandbox Code Playgroud)

会像这样更好地缩进:

NSArray *persons = @[
@{
@"name": @"Bob",
@"pet": @"cat"
},
@{
@"name": @"Alice",
@"pet": @"dog"
}
];
Run Code Online (Sandbox Code Playgroud)

你能教Xcode关于缩进Objective-C文字吗?

还有另一种选择吗?

注意:我已经知道我可以"强制"缩进cmdopt],但是这在复制/粘贴时消失,并且无法解决问题.

xcode indentation auto-indent objective-c-literals

16
推荐指数
1
解决办法
890
查看次数

VIM中的Javascript缩进

我试图让VIM使用'='和相关命令缩进Javascript.当我尝试自动缩进以下内容时,例如:

   new function($) {
     $.fn.setCursorPosition = function(pos) { 
       if ($(this).setSelectionRange) {
         $(this).setSelectionRange(pos, pos);
       } else if ($(this).createTextRange) {
         var range = $(this).createTextRange();
         range.collapse(true);
         range.moveEnd('character', pos);
         range.moveStart('character', pos);
         range.select();
       }
Run Code Online (Sandbox Code Playgroud)

结果是相当荒谬的:

       new function($) {
       $.fn.setCursorPosition = function(pos) {
       if ($(this).setSelectionRange) {
       $(this).setSelectionRange(pos, pos);
       } else if ($(this).createTextRange) {
       var range = $(this).createTextRange();
       range.collapse(true);
       range.moveEnd('character', pos);
       range.moveStart('character', pos);
       range.select();
       }
Run Code Online (Sandbox Code Playgroud)

我已经设定了set syntax=javascript,我已经设定filetype为:

filetype detection:ON  plugin:ON  indent:ON
Run Code Online (Sandbox Code Playgroud)

虽然我已经尝试了每一种排列.我已经尝试了smartindent,autoindentcindent,但似乎没有任何东西给Vim预期的缩进的正确效果.我已经定了tabstop=4.

我安装了javascript.vim, …

javascript vim indentation auto-indent

15
推荐指数
3
解决办法
1万
查看次数

如何在VIM中启用文件特定的选项卡缩进设置?

我相信有一种方法可以在文件中编写注释,vim将使用该方法覆盖默认的tab键和缩进值.

有人能指出我有关此功能的信息以及如何使用它吗?

vim configuration indentation auto-indent

14
推荐指数
1
解决办法
8028
查看次数

Sublime Text 3中的自动缩进方法链接

当我输入以下javascript代码(确切的击键):

myObject
.doSomething()
.doSomethingElse();
Run Code Online (Sandbox Code Playgroud)

我希望它能自动成为以下......

myObject
    .doSomething()
    .doSomethingElse();
Run Code Online (Sandbox Code Playgroud)

......和其他程序员一样,对吧?

如何启用此功能,为什么默认情况下不启用?

javascript code-formatting auto-indent sublimetext sublimetext3

14
推荐指数
1
解决办法
1283
查看次数

在Emacs中全局禁用自动缩进

如何在全局或仅在某些模式下禁用Emacs中的自动缩进?

我为RubyOnRails安装了许多软件包(ruby,html,js,css).

假设我想禁用css-mode的autoindent.

emacs indentation auto-indent

12
推荐指数
2
解决办法
1万
查看次数

如何在Vim中自动添加Ruby源代码

假设我有set cindent.vimrc
def func()后面Enter,然后键入end,它缩进(不对齐def)

如何缩进的end关键字(将其调整到def).

即使使用endwise.vim plugin不解决问题
https://github.com/tpope/vim-endwise.git
它增加了自动end关键字,但再次indented

ruby vim auto-indent

12
推荐指数
2
解决办法
1万
查看次数

Vim:打击进入时如何缩进打开的支架或支架?

我已经用Vim编写了一段时间的Python,但有一点我无法弄清楚如何将它设置为自动缩进到最后一个打开的paren的级别.

根据pep8,如果你有一个开放的paren,你需要打破线以适应80列,那么你应该继续在那个开放的paren下一行.例:

calling_some_really_long_function(that, has, way, too, many, arguments, to, fit,
                                  on, one, line)
Run Code Online (Sandbox Code Playgroud)

显然这是一个疯狂的例子,但这就是你应该如何在python中打破你的界限.

我真正想要做的就是设置Vim,这样当我输入时fit,<cr>它会将光标放在open paren右边的下一行,所以我可以输入on,等等而不是某种组合之前<tab><space>键.

我认为我永远不会相信Vim中的自动格式化程序用于python代码,但如果它也能起作用则可以获得奖励积分.

python vim pep8 auto-indent

12
推荐指数
1
解决办法
2181
查看次数

使用Visual Studio 2015禁用注释的自动缩进

当我在安装了Resharper 9.0.0.0的Visual Studio 2015中保存C#文件时,我查看并搜索了禁用注释缩进的方法.

在开始编写实际代码之前,我想要伪代码.然而,我一直在调整Visual Studio和Resharper的设置无济于事.所以例如我希望评论看起来像:

  private string ToggleString(string input)
    {
        // If input.length is between 1-100
            // All the uppercase letters converted to lowercase.
            // All the lowercase letters converted to uppercase
        // else
            // Return a constructive message.

        return input;
     }
Run Code Online (Sandbox Code Playgroud)

当我保存CTRL+ s它结果是这样的:

private string ToggleString(string input)
{
    // If input.length is between 1-100
    // All the uppercase letters converted to lowercase.
    // All the lowercase letters converted to uppercase
    // else
    // Return a …
Run Code Online (Sandbox Code Playgroud)

c# resharper comments auto-indent visual-studio

12
推荐指数
2
解决办法
1604
查看次数