如何从$吞咽右括号,报价和括号p $ pvent崇高文字2? [英] How to prevent Sublime Text 2 from swallowing closing brackets, quotes and parentheses?

查看:203
本文介绍了如何从$吞咽右括号,报价和括号p $ pvent崇高文字2?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

崇高具有这种行为有时当你在有很多括号内输入结构这实在是烦人。当键入它增加了()键,把光标在中间,所有的罚款,不过,若你将键入它会悄悄地吞下右括号。

这长期打字时,正则表达式,因为括号变得不平衡pretty快,真的很烦,这是推动我疯了。所以,你最终像建筑(([A-Z])

所以,问题是 - 是有办法禁用此?如果键入一个右括号我希望它留下来,不被吞噬。

我已经经历了崇高CONFIGS检查,用Google搜索,但似乎没有人介意这种行为。我使用它错了吗?

更新

您可能想看看<一个href=\"http://stackoverflow.com/questions/8537844/is-there-a-shortcut-in-pycharm-or-sublime-text-2-for-jump-out-of-matching-bracke#answer-11711589\">Sublime:跳出括号匹配 快捷方式为好。

完整版,使您可以通过与键入(),但不会吞下结束符号,如果你输入的任何文本:

  {钥匙:\\],命令:插入,ARGS:{人物:\\},背景 :
      [
          {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
          {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
          {键:following_text,操作员:regex_contains,操作数:^ \\,MATCH_ALL:真}
          {键:preceding_text,操作员:regex_contains,操作数:[^ \\] $,MATCH_ALL:真}
      ]
  },
  {钥匙:[)],命令:插入,ARGS:{人物:)},背景:
      [
          {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
          {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
          {键:following_text,操作员:regex_contains,操作数:^ \\\\),MATCH_ALL:真}
          {键:preceding_text,操作员:regex_contains,操作数:[^(] $,MATCH_ALL:真}
      ]
  },
  {钥匙:[)],命令:动,ARGS:{本经:人物,前进:真正},背景:
      [
          {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
          {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
          {键:following_text,操作员:regex_contains,操作数:^ \\\\),MATCH_ALL:真}
          {键:preceding_text,操作员:regex_contains,操作数:\\\\($,MATCH_ALL:真}
      ]
  },
  {钥匙:'],命令:插入,ARGS:{人物:'},背景:
      [
          {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
          {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
          {关键:following_text,经营者:regex_contains,操作数:^',MATCH_ALL:真正},
          {关键:preceding_text,经营者:regex_contains,操作数:'$,MATCH_ALL:真正}
      ]
  },
  {钥匙:[]],命令:插入,ARGS:{人物:]},背景:
      [
          {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
          {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
          {关键:following_text,经营者:regex_contains,操作数:^ \\\\],MATCH_ALL:真正},
          {键:preceding_text,操作员:regex_contains,操作数:[$,MATCH_ALL:真}
      ]
  },
  {钥匙:}],命令:插入,ARGS:{人物:},背景:
      [
          {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
          {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
          {键:following_text,操作员:regex_contains,操作数:^ \\\\},MATCH_ALL:真}
          {键:preceding_text,操作员:regex_contains,操作数:{$,MATCH_ALL:真}      ]
  }


解决方案

添加到您的用户键绑定文件

  {钥匙:[)],命令:插入,ARGS:{人物:)},背景:
    [
        {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
        {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
        {键:following_text,操作员:regex_contains,操作数:^ \\\\),MATCH_ALL:真}
    ]
}

它将覆盖一键绑定的,而不是插入一个右括号只是移动光标一个位置前移。所以基本上它应该做的正是你想要的。

如果你想完全禁止这种行为,对于各种的括号和引号,这里是完整的用户按键绑定部分:

  {钥匙:\\],命令:插入,ARGS:{人物:\\},背景 :
    [
        {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
        {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
        {键:following_text,操作员:regex_contains,操作数:^ \\,MATCH_ALL:真}
    ]
},
{钥匙:[)],命令:插入,ARGS:{人物:)},背景:
    [
        {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
        {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
        {键:following_text,操作员:regex_contains,操作数:^ \\\\),MATCH_ALL:真}
    ]
},
{钥匙:'],命令:插入,ARGS:{人物:'},背景:
    [
        {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
        {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
        {关键:following_text,经营者:regex_contains,操作数:^',MATCH_ALL:真正}
    ]
},
{钥匙:[]],命令:插入,ARGS:{人物:]},背景:
    [
        {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
        {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
        {关键:following_text,经营者:regex_contains,操作数:^ \\\\],MATCH_ALL:真正}
    ]
},
{钥匙:}],命令:插入,ARGS:{人物:},背景:
    [
        {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
        {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
        {键:following_text,操作员:regex_contains,操作数:^ \\\\},MATCH_ALL:真}
    ]
}

编辑:

如果你想跳过右括号如果光标是一个左方括号之后,并打印在其他情况下,您可以拆分的键绑定到beetween这两种可能性区别:

  {钥匙:[)],命令:插入,ARGS:{人物:)},背景:
    [
        {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
        {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
        {键:following_text,操作员:regex_contains,操作数:^ \\\\),MATCH_ALL:真}
        {键:preceding_text,操作员:regex_contains,操作数:[^(] $,MATCH_ALL:真}
    ]
},
{钥匙:[)],命令:动,ARGS:{本经:人物,前进:真正},背景:
    [
        {关键:setting.auto_match_enabled,经营者:平等,操作数:真正},
        {关键:selection_empty,经营者:平等,操作数:真的,MATCH_ALL:真正},
        {键:following_text,操作员:regex_contains,操作数:^ \\\\),MATCH_ALL:真}
        {键:preceding_text,操作员:regex_contains,操作数:\\\\($,MATCH_ALL:真}
    ]
},

第一个插入charcater如果preceding文本不与左括号结束。第二个,如果它有一个开口支架向前结束移动光标一个位置。如果你是一个有点熟悉规则前pressions可以为所有其他类型的括号和引号的做同样的。

Sublime has this behaviour which is really annoying sometimes when you have to type in constructions with lots of brackets. When you type ( it adds () and puts the cursor in the middle, all fine, if you however will type ) it will silently swallow the closing bracket.

This is really annoying when typing long regexps because the brackets gets unbalanced pretty quick and this is driving me crazy. So you end up with constructions like (([a-z]).

So the question is - is there a way to disable this? If I type a closing bracket I want it to stay, not be swallowed.

I have checked through Sublime configs, googled, but nobody seems to mind this behaviour. Am I using it wrong?

Update

You might want to check out Sublime: Jump out of matching brackets shortcut as well.

Full version that allows you to type through with () but will not swallow the closing symbol if you have entered any text:

  { "keys": ["\""], "command": "insert", "args": {"characters": "\""}, "context":
      [
          { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
          { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
          { "key": "following_text", "operator": "regex_contains", "operand": "^\"", "match_all": true },
          { "key": "preceding_text", "operator": "regex_contains", "operand": "[^\"]$", "match_all": true }
      ]
  },
  { "keys": [")"], "command": "insert", "args": {"characters": ")"}, "context":
      [
          { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
          { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
          { "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true },
          { "key": "preceding_text", "operator": "regex_contains", "operand": "[^(]$", "match_all": true }
      ]
  },
  { "keys": [")"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
      [
          { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
          { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
          { "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true },
          { "key": "preceding_text", "operator": "regex_contains", "operand": "\\($", "match_all": true }
      ]
  },
  { "keys": ["'"], "command": "insert", "args": {"characters": "'"}, "context":
      [
          { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
          { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
          { "key": "following_text", "operator": "regex_contains", "operand": "^'", "match_all": true },
          { "key": "preceding_text", "operator": "regex_contains", "operand": "'$", "match_all": true }
      ]
  },
  { "keys": ["]"],"command": "insert", "args": {"characters": "]"}, "context":
      [
          { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
          { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
          { "key": "following_text", "operator": "regex_contains", "operand": "^\\]", "match_all": true },
          { "key": "preceding_text", "operator": "regex_contains", "operand": "[$", "match_all": true }
      ]
  },
  { "keys": ["}"], "command": "insert", "args": {"characters": "}"}, "context":
      [
          { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
          { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
          { "key": "following_text", "operator": "regex_contains", "operand": "^\\}", "match_all": true },
          { "key": "preceding_text", "operator": "regex_contains", "operand": "{$", "match_all": true }

      ]
  }

解决方案

add this to your user keybindings file

{ "keys": [")"], "command": "insert", "args": {"characters": ")"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true }
    ]
}

it will override the one keybinding that instead of inserting a closing bracket just moves the cursor one position forward. so essentially it should do exactly what you want.

if you want to disable this behaviour completely, for all kinds of brackets and quotes, here is the complete user keybindings part:

{ "keys": ["\""], "command": "insert", "args": {"characters": "\""}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^\"", "match_all": true }
    ]
},
{ "keys": [")"], "command": "insert", "args": {"characters": ")"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true }
    ]
},
{ "keys": ["'"], "command": "insert", "args": {"characters": "'"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^'", "match_all": true }
    ]
},
{ "keys": ["]"],"command": "insert", "args": {"characters": "]"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^\\]", "match_all": true }
    ]
},
{ "keys": ["}"], "command": "insert", "args": {"characters": "}"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^\\}", "match_all": true }
    ]
}

EDIT:

In case you want to skip the closing bracket if the cursor is right after an opening bracket and print it in all other cases, you can split your keybindings up to distinguish beetween these two possibilities:

{ "keys": [")"], "command": "insert", "args": {"characters": ")"}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true },
        { "key": "preceding_text", "operator": "regex_contains", "operand": "[^(]$", "match_all": true }
    ]
},
{ "keys": [")"], "command": "move", "args": {"by": "characters", "forward": true}, "context":
    [
        { "key": "setting.auto_match_enabled", "operator": "equal", "operand": true },
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
        { "key": "following_text", "operator": "regex_contains", "operand": "^\\)", "match_all": true },
        { "key": "preceding_text", "operator": "regex_contains", "operand": "\\($", "match_all": true }
    ]
},

The first one inserts the charcater if the preceding text doesn't end with an opening bracket. The second one moves the cursor one position forward if it does end with an opening bracket. If you are a little familiar with regular expressions you can do the same for all other kinds of brackets and quotes.

这篇关于如何从$吞咽右括号,报价和括号p $ pvent崇高文字2?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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