我想创建一个键盘快捷键(例如 CTRL + T ),该快捷键会在出现固定文本后自动将光标移动到该行,例如为Access to XMLHttpRequest at 'localhost:3000/articles' from origin 'http://localhost:8080' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.
。
示例:
&todo
按 CTRL + T 会将光标自动移动到以foo
bar
&todo
fix bug #783
blah
blah2
开头的行。
目前我正在这样做:
fix ...
, ENTER &todo
底部面板)但这需要太多动作。
如何在单个快捷键中执行此操作?
答案 0 :(得分:0)
我找到了一个解决方案:为此,首先在ul {
position: absolute;
left: 0;
list-style: none;
padding: 0;
padding-left: 2rem;
margin: 0;
display: inline-flex;
transform: translateX(0);
animation: animation1 20s linear infinite;
animation-direction: alternate;
}
li {
height: 6rem;
margin: 1rem;
box-shadow: 0px 0px .5rem rgba(0, 0, 0, .2);
width: 15rem;
border-radius: .5rem;
padding: .5rem;
box-sizing: border-box;
line-height: 7rem;
}
img {
max-height: 100%;
max-width: 100%;
}
@keyframes animation1 {
from {
left: 0;
transform: translateX(0);
}
to {
left: 100%;
transform: translateX(-100%);
}
}
中创建一个包含以下内容的gototodo.py
文件:
"C:\Users\User\AppData\Roaming\Sublime Text 2\Packages\User\"
然后将其添加到import sublime, sublime_plugin
class GototodoCommand(sublime_plugin.TextCommand):
def run(self, edit):
contents = self.view.substr(sublime.Region(0, self.view.size())) # https://stackoverflow.com/questions/20182008/sublime-text-3-api-get-all-text-from-a-file
a = contents.find('&todo')
cursors = self.view.sel()
cursors.clear()
location = sublime.Region(a, a)
cursors.add(location)
self.view.show_at_center(location)
(row, col) = self.view.rowcol(self.view.sel()[0].begin()) # go to the next line
self.view.run_command("goto_line", {"line": row+2})
中:
"C:\Users\User\AppData\Roaming\Sublime Text 2\Packages\User\Default (Windows).sublime-keymap"
完成!