这玩意的设置是门艺术

20230117 精细化处理tab

  • 思路转化, 只有在行首才能输入tab字符
  • 基本决定放弃了, vscode简单好多倍
// 这是备用的json, 放弃了, 有空再弄吧
[

  { "keys": ["enter"], "command": "noop", "context":
   [
     { "key": "auto_complete_visible" },
     { "key": "setting.auto_complete_commit_on_tab", "operand": false }
   ]
  },
  // 先要去掉tab的本身功能, 此时要精确一点


  { 
    "keys": ["tab"], "command": "noop", "args": {"mini": true, "default": "\t"},
    "context":
    [
      { "key": "auto_complete_visible", "operand": false },
      { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
      { "key": "setting.tab_completion", "operator": "equal", "operand": true },
      { "key": "preceding_text", "operator": "regex_match", "operand": ".*\\w", "match_all": true },
    ]
  },
  { "keys": ["tab"], "command": "insert", "args": {"characters": "\t"} },

  { "keys": ["tab"], "command": "insert", "args": {"characters": "\t"} },
  { "keys": ["tab"], "command": "auto_complete", "args": {"mini": true, "default": "\t",  "commit_single": true},
   "context":
   [
     { "key": "auto_complete_visible", "operand": false },
     { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
     { "key": "setting.tab_completion", "operator": "equal", "operand": true },
     { "key": "preceding_text", "operator": "regex_match", "operand": ".*\\w", "match_all": true },
   ]
  },

  { "keys": ["tab"], "command": "auto_complete", "args": {"snippets_only": true, "default": "\t", "commit_single": true},
   "context":
   [
     { "key": "auto_complete_visible", "operand": false },
     { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
     { "key": "setting.tab_completion", "operator": "equal", "operand": false },
     { "key": "preceding_text", "operator": "regex_match", "operand": ".*\\w", "match_all": true },
   ]
  },

  { "keys": ["tab"], "command": "expand_snippet", "context":
   [{ "key": "has_snippet" }, ]
  },
  { "keys": ["tab"], "command": "reindent", "context":
   [
     { "key": "setting.auto_indent", "operator": "equal", "operand": true },
     { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
     { "key": "preceding_text", "operator": "regex_match", "operand": "^$", "match_all": true },
     { "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true }
   ]
  },
  { "keys": ["tab"], "command": "indent", "context":
   [{ "key": "text", "operator": "regex_contains", "operand": "\n" } ]
  },
  { "keys": ["tab"], "command": "move", "args": {"by": "lines", "forward": true}, "context":
   [
     { "key": "overlay_has_focus", "operator": "equal", "operand": true }
   ]
  },
  { "keys": ["tab"], "command": "next_field", "context":
   [{ "key": "has_next_field", "operator": "equal", "operand": true }]
  },
  { "keys": ["tab"], "command": "commit_completion", "context":
   [{ "key": "auto_complete_visible" }, ]
  },






  {
    "keys": ["tab"],
    "command": "move",
    "args": {"by": "lines", "forward": true},
    "context": [{"key": "auto_complete_visible"}]
  },
  {
    "keys": ["shift+tab"],
    "command": "move",
    "args": {"by": "lines", "forward": false},
    "context": [{"key": "auto_complete_visible"}]
  },

  { "keys": ["tab"], "command": "indent" },
  { "keys": ["shift+tab"], "command": "unindent" },




  {
    "keys": ["ctrl+."],
    "command": "emmet_enter_abbreviation"
  },



  // 配置扩展为单键

  // {
  //  "keys": ["tab"],
  //  "command": "emmet_expand_abbreviation",
  //  "context": [{ "key": "selector",
  //   "operator": "equal", 
  //  "operand": "source.html, source.htm" }]
  // },
  // { "keys": ["tab"], "command": "commit_completion", 
  //  "context": [
  //   { "key": "auto_complete_visible" },
  //   { "key": "setting.auto_complete_commit_on_tab", "operand": false },
  //   { "key": "selector",
  //    "operator": "not_equal", 
  //   "operand": "source.html, source.htm, source.rb, source.ruby, source.sql" },
  //  ]
  // },
  // { "keys": ["tab"], "command": "auto_complete", "args": {"mini": true, "default": "\t"},
  // "context":
  // [
  //  { "key": "auto_complete_visible", "operand": false },
  //  { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
  //  { "key": "setting.tab_completion", "operator": "equal", "operand": true },
  //  { "key": "preceding_text", "operator": "regex_match", "operand": ".*\\w", "match_all": true },
  // ]
  // },
  // { "keys": ["tab"], "command": "expand_snippet", "context":
  //  [{ "key": "has_snippet" }, ]
  // },




  //好不容易找到了可以做自动格式化的组合按键
  { 
    "keys": ["ctrl+super"], "command": "beautify_ruby", 
    "context": { "key": "selector",
                "operator": "equal", 
                "operand": "source.rb, source.ruby" }

  },
  { 
    "keys": ["ctrl+super"], "command": "sql_beautifier", 
    "context": { "key": "selector",
                "operator": "equal", 
                "operand": "source.sql" }

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

    [
      { "key": "selector",
       "operator": "not_equal", 
       "operand": "source.rb, source.ruby, source.sql" },
      { "key": "setting.auto_indent", "operator": "equal", "operand": true },
      { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
      { "key": "preceding_text", "operator": "regex_match", "operand": "^$", "match_all": true },
      { "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true }
    ]

  },

]


后记更新20220908

  • beautify ruby 多用几次快捷键就会犯病, 因此, 还是要把她的快捷键单独拆分出来
  • ctrl+shift+super

需求

  • 可以自动扩展, 并且不放在tab上面, 因为tab太常用了:
    • 缩进
    • 插入tab字符
  • 可以格式化, 原本的快捷键记不住, 最好这个按键和tab有关, 但是很不幸
    • alt-tab用了一个
    • ctrl-tab, 一般是窗口内切换tab
    • shift-tab, 减少缩进
    • cmd-tab, 全局切换应用

格式化: ctrl+cmd

  • ctrl cmd, 目前为止OK的方案
  • Ctrl shift tab是一个切换功能 因此ctrl shift也是不合理的
  • 试试shift alt tab/ctrl shift alt
  • shift+alt, 这个也不可以, 很神奇, 貌似有mode, 每次要添加一个alt+space才行
  • ctrl+alt, 这个不行, 也不知道为啥
  • alt + space, 这是一个真实的按键输入, 因此不行, 很多时候, 会输入一个怪字符

自动补全: alt

  • alt, 必须单键, 因为真的有按键顺序
  • shift+ctrl , 注意有按键顺序, 所以不是 ctrl+shift

a全局化处理: caps->alt

  • 为了方便按alt, 把全局caps(大写锁定)->alt

各种问题

  • sql beautifer没有效果
    • 删除beautifersql, 这玩意8年没维护了
  • 然后, 格式化sql/json都报错:
    • Error: This is not a Ruby file
    • 清理了shortcuts的json配置的注释之后问题解决. sublime估计也快倒闭了

样例配置

[

	{ "keys": ["enter"], "command": "noop", "context":
		[
			{ "key": "auto_complete_visible" },
			{ "key": "setting.auto_complete_commit_on_tab", "operand": false }
		]
	},
  // 先要去掉tab的本身功能
  { 
  	"keys": ["tab"], "command": "noop", "args": {"mini": true, "default": "\t"},
  	"context":
  	[
  		{ "key": "auto_complete_visible", "operand": false },
  		{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
  		{ "key": "setting.tab_completion", "operator": "equal", "operand": true },
  		{ "key": "preceding_text", "operator": "regex_match", "operand": ".*\\w", "match_all": true },
  	]
  },
  { "keys": ["tab"], "command": "insert", "args": {"characters": "\t"} },
  {
  	"keys": ["tab"],
  	"command": "move",
  	"args": {"by": "lines", "forward": true},
  	"context": [{"key": "auto_complete_visible"}]
  },
  {
  	"keys": ["shift+tab"],
  	"command": "move",
  	"args": {"by": "lines", "forward": false},
  	"context": [{"key": "auto_complete_visible"}]
  },

  { "keys": ["tab"], "command": "indent" },
  { "keys": ["shift+tab"], "command": "unindent" },




  {
  	"keys": ["ctrl+."],
  	"command": "emmet_enter_abbreviation"
  },



// 配置扩展为单键

{
	"keys": ["alt"],
	"command": "emmet_expand_abbreviation",
	"context": [{ "key": "selector",
		"operator": "equal", 
	"operand": "source.html, source.htm" }]
},
{ "keys": ["alt"], "command": "commit_completion", 
	"context":	[
		{ "key": "auto_complete_visible" },
		{ "key": "setting.auto_complete_commit_on_tab", "operand": false },
		{ "key": "selector",
			"operator": "not_equal", 
		"operand": "source.html, source.htm, source.rb, source.ruby, source.sql" },
	]
},
{ "keys": ["alt"], "command": "auto_complete", "args": {"mini": true, "default": "\t"},
"context":
[
	{ "key": "auto_complete_visible", "operand": false },
	{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
	{ "key": "setting.tab_completion", "operator": "equal", "operand": true },
	{ "key": "preceding_text", "operator": "regex_match", "operand": ".*\\w", "match_all": true },
]
},
{ "keys": ["alt"], "command": "expand_snippet", "context":
	[{ "key": "has_snippet" }, ]
},




//好不容易找到了可以做自动格式化的组合按键
{ 
	"keys": ["ctrl+super"], "command": "beautify_ruby", 
	"context": { "key": "selector",
		"operator": "equal", 
	"operand": "source.rb, source.ruby" }

},
{ 
	"keys": ["ctrl+super"], "command": "sql_beautifier", 
	"context": { "key": "selector",
		"operator": "equal", 
	"operand": "source.sql" }

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

	[
		{ "key": "selector",
			"operator": "not_equal", 
		"operand": "source.rb, source.ruby, source.sql" },
		{ "key": "setting.auto_indent", "operator": "equal", "operand": true },
		{ "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
		{ "key": "preceding_text", "operator": "regex_match", "operand": "^$", "match_all": true },
		{ "key": "following_text", "operator": "regex_match", "operand": "^$", "match_all": true }
	]

},

]