Simplify the work with the Russian text in Sublime Text 3 + Vintage
If you're just getting started: 1) use Sublime Text and/or 2) to use the plugin Vintage and/or 3) to edit a lot of text in Russian (or Vice versa English) using ST3+Vintage, it is likely already felt some pain associated with teams assigned to punctuation marks— "$", ";", ".", ",", """ etc. In the small note under the cut I want to offer you a pair of crutches that help the pain greatly eased.
Maybe you didn't know that a significant part of the plugin is Vintage tutu bindingof standard Vim-oriented teams to implement them in the plugin, for example:
the
{ "keys": [";"], "command": "set_repeat_move_to_character_motion",
"context": [{"key": "setting.command_mode"}]
}
So the specified problem, the roots lie in the fact that this binding does not know whether the pressed key is 4/$/; (and it is necessary to perform "end of line"); or/W/: (and it is necessary to perform a "rescan" symbol). That is actually binding does not know the current layout. If the plugin could tell the current layout, then everything would be great.
And it turns out that to make this card possible for this bindingof is "context" that can look at the setting:
the
{"key": "setting.is_rus"}
by using this trick we can change the behavior of the symbol ";" on "to the end of the row" only if the setting "is_rus" exposed to true:
the
{ "keys": [";"], "command": "set_motion", "args": {
"motion": "vi_move_to_hard_eol",
"motion_args": {"repeat": 1, "extend": true},
"inclusive": true,
"clip_to_line": true },
"context": [{"key": "setting.command_mode"},{"key": "setting.is_rus"}]
}
unfortunately this solution is not perfect — if you edit a file where a roughly equal number of text in Russian and English languages, one of languages in any case will suffer. Moreover, if you at least once in half an hour switching between files in different languages, each time to climb in the settings is not very convenient.
of Course, I would like to show you a couple of lines that would be automatically looked at the system layout and it fills in the value "is_rus". But now I don't know how to do it — maybe later I'll deal with it and will definitely share the results.
But still I have for you the second crutch that allows you and the pain greatly eased. It is based on the team "toggle_setting", which allows you to toggle the specified Boolean setting, and that we will hang on F8:
the
{ "keys": ["f8"], "command": "toggle_setting", "args": {"setting": "is_rus"} }
In the end, offers approximately the following way: write the code stumble on one of the teams, matyugayutsya, hit F8, go slow and easy. After half an hour you are going to write article on Habr, stumble on one of the teams, matyugayutsya, I press F8, appends the article quietly.
as a base to share with you bindingly, which had stumble after opening this set of crutches.
the
{ "keys": ["\"", "<character>"], "command": "vi_replay_macro",
"context": [{"key": "setting.command_mode"},{"key": "setting.is_rus"}]
},
{ "keys": [";"], "command": "set_motion", "args": {
"motion": "vi_move_to_hard_eol",
"motion_args": {"repeat": 1, "extend": true},
"inclusive": true,
"clip_to_line": true },
"context": [{"key": "setting.command_mode"},{"key": "setting.is_rus"}]
},
{ "keys": ["."], "command": "show_panel", "args":
{
"panel": "incremental_find",
"select_text": false,
"reverse": false
},
"context": [{"key": "setting.command_mode"},{"key": "setting.is_rus"}]
}
If someone can suggest a better solution to this problem, please tell me in the comments.
Комментарии
Отправить комментарий