How to move the cursor to the end of the tag in Sublime Text 2?

爷,独闯天下 提交于 2019-12-11 07:54:41

问题


When I type the start of a tag, Sublime Text will auto-complete the end of the tag and position the cursor inside the tag.

<code>|</code>

I use | to represent the cursor. So when I finished the contents inside the tag, I want to move the cursor to the end of the tag like this:

<code>blabla</code>|

To do this, now I have to press Right button to move the cursor character by character, which is not efficient. Is there any shortcut to move the cursor to the end of the tag directly?


回答1:


You could also create a macro. This may be valuable if your tags cover multiple lines. Save the following as something like move_to_end_tag.sublime-macro in Packages/User.

[
    {
        "args":
        {
            "to": "tag"
        },
        "command": "expand_selection"
    },
    {
        "args":
        {
            "by": "characters",
            "forward": true
        },
        "command": "move"
    }
]

You can then create a keybinding for the action.

{ 
    "keys": ["ctrl+shift+alt+right"], 
    "command": "run_macro_file", 
    "args": {"file": "res://Packages/User/move_to_end_tag.sublime-macro"} 
}

Of course, you can change the keys to whatever you like.




回答2:


I'm working in Sublime Text 3 rather than 2, but the End button (for me, between the delete and page down) does the trick for me.




回答3:


I found that annoying as well. Personally, taking the End key binding and applying it to Shift+Space works well enough for my purposes.

If that's easier for you, you can add this line to your user key bindings:

{ "keys": ["shift+space"], "command": "move_to", "args": {"to": "eol", "extend": false} }

Using a macro as skuroda suggested is a good option as well since you end up with more control of the cursor placement.




回答4:


For curly braces and parentheses you can use Control + M.

Not sure about angle brackets in markup though.



来源:https://stackoverflow.com/questions/18138848/how-to-move-the-cursor-to-the-end-of-the-tag-in-sublime-text-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!