简体   繁体   中英

Shortcut to paste multiple lines - Sublime Text 2

I am using Windows 8 OS

I have some projects where I repeatedly add the same tags to different types of elements, but the format of how the elements are presented through code always stays the same. I'm looking for shortcuts that will help me do these tasks quickly. Is there a shortcut that lets you add the same tag for multiple lines that you specify? I know you can do (CTR + F3) To select clone tags and change all of them, but I want to add tags to elements that previously had no tag. Is there a way you can make your own shortcuts for your tags, like if I type in "li" It will automatically put in "" and all I have to do is hit enter?

Here is an example of the elements and tags I added:

<ul>
<li type="square">Extra Grip
<li type="square">Made of Titanium
<li type="square">Built in Selsoft Processor
<li type="square">Portable</ul>

<b>MBS:</b> 44 kN (10000 lbf)<br>
<b>Weight:</b> 1 lbs 13.2 oz (828 g)<br>
<b>Length:</b> 14.40" (36.6 cm)<br>
<b>Width:</b> 3.75" (9.5 cm)<br>
<b>Height:</b> 1.00" (2.5 cm)<br>
<b>Material:</b> Titanium 

Ctrl+C, Ctrl+X and Ctrl+V let you copy/cut/paste lines if you don't select anything. So, Ctrl+X doesn't "delete" a line, it cuts it. To delete a line, the default shortcut is Ctrl+Shift+K :)

Highlighting a bunch of lines then hitting Cmd (Ctrl?) +Shift+L gives you multi-cursors on each line. I do that, followed by Cmd + Right arrow (End?) to get easily get a cursor at the end of a series of lines to simultaneously type something after each.

Ctrl+Shift+J expands the selection to the indentation level of the current line. So if you want to select a block of code with the same indentation it's really useful.

Alt + F3 select all occurrences of current word for multiple editing. Very useful.

A few written about in more detail: http://whiletruecode.com/post/7-handy-text-manipulation-tricks-sublime-text-2

Have you tried to make your own snippets? It may not be exactly what you are asking for, but could be another way to do it.

Try the New Snippet command in the Tools -menu and add the following and save it:

<snippet>
    <content><![CDATA[
<li type="square">${1:Item} ${2:}
]]></content>
    <tabTrigger>li</tabTrigger>
</snippet>

This will enter an <li> -tag in the current file if you type li and then press Tab . You can also add a <scope> tag to limit it to HTML-files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM