text
text
text
text
after the editing, those text becomes to
1 text
2 text
3 text
4 text
It's easy in Notepad ++ with the Column Editor, but I don't know how to do the same in Sublime Text 2.
The Text Pastry plugin does the job very well. It offers the Insert Numbers Syntax.
Select multiple lines with CMD+SHIFT+L (Sublime default):
text|
text|
text|
text|
Move the cursor where you want it:
| text
| text
| text
| text
And insert numbers with Text Pastry by hitting CMD+ALT+N and entering 1 space 1 space 0:
1| text
2| text
3| text
4| text
Where 1 space 1 space 0 stands for:
Integer to start with 1
Increment by 1
Padd leading zeros 0
Replace CMD with CTRL on Windows or Linux machines.
copy of this post https://stackoverflow.com/a/64083371/5902698
You want to have a number at each row that you selected, but not the same. For exemple, you select 5 cursors and you want to write 1 2 3 4 5.
select your 5 cursors (maybe you can use the shortcut ctrl + shift + L)
ctrl + shift + P and select arithmetic
Because you have 5 cursors, it propose 1 2 3 4 5
If you want you can change your step of iteration
Or start from an other number than 1
Add even numbers
For this particular case you can use Increment Selection package. Just press Ctrl+Alt+I (Command+Control+I) while having multiple cursors at the beginning of each line.
In addition to melinath answer, here's an example of how to do it:
You will need Package Control first. It shouldn't take more than 30 seconds to install both things.
Steps:
Install Package Control.
Open Command Palette: Ctrl+Shift+P (Mac: Command+Shift+P).
Type Install Package Control and click to install.
Install Increment Selection package.
Open Command Palette again.
Type Package Control: Install Package, click on it and wait a short period.
Type Increment Selection and click on it to install.
Add line numbers to the beginning of each line.
Select all lines with Ctrl+A (Mac: Command+A)
Change selection to multiple lines with Ctrl+Shift+L (Mac: Command+Shift+L)
Go to the start of each line by pressing Home (Mac: Command+←)
Use Increment Selection with Ctrl+Alt+I (Mac: Command+Control+I)
Result:
Other examples for Increment Selection
Increment Selection can also replace numbers, prefix numbers with leading zeroes, increment letters, increment by a step and more.
[1] text [1] text [1] -> 1| text 2| text 3|
[a] text [a] text [a] -> a| text b| text c|
[01] text [01] text [01] -> 01| text 02| text 03|
[05,3] text [05,3] text [05,3] -> 05| text 08| text 11|
[5,-1] text [5,-1] text [5,-1] -> 5| text 4| text 3|
Hint: [] stands for a selection, | stands for a caret.
Featured similar plugins
Selection Evaluator: Evaluate selected mathematical expression with Ctrl+Shift+M (Mac: Command+Shift+M).
The IncrementSelection plugin enables this behavior. If you have Package Control installed, you can just search for and install it. Easy peasy!
Use Emmet package try this :
{$ text${newline}}*4
My simple workaround (up until now when I found this thread) was to go to my spreadsheet editor generate the sequence there, copy, back to subl, expand the cursor over however many lines and paste.
This approach can be applied in any text editor that allows you to expand (clone) the cursor.
You can use the plugin ConyEdit to do this, use its command line cc.abl '#1 ' to append before lines with the contents that you want.
#Nicoolasens This answer is great! Just adding one detail: On macOS you can follow these steps to put a curser at the end of each line:
Use command+A to choose all lines;
Use command+shift+L to put a
curser after each line.
Related
I need to add a list of names in front of a current list of number in sublime and having a hard time figuring out how to do it.
Basically if I have list 1
Tom
Jerry
Mary
Sue
and
12
34
45
39
I need the final text file to read
12 Tom
34 Jerry
45 Mary
39 Sue
I would do it by hand, but its around 800 entries each with about 25 sets of numbers after it.
Thanks!
select list 1
press Ctrl + Shift + L to split the selection into lines
cut the selected lines
select list 2
press Ctrl + Shift + L to split the selection into lines
press End to go to the end of each line & add a space character
paste the previously copied text
Note:
This only works if both selections have the same number of lines.
I working on setting up a new site and Volusion doesn't appear to have any tools available to create dependent options. I will have products on the store that will have multiple option combinations (see example below)
Option 1: Color (Red, Blue,Green)
Based on the selection of option 1, I need the correct option 2 to appear.
Option 2: Personalization
If red is selected---Line 1: 5 characters Line 2: 10 characters
If blue is selected---Line 1: 5 characters
If green is selected-- Line 1: 8 characters Line 2: 20 characters
While I would LOVE for the personaization options to appear and link to the option 1, I would also be okay to just use the "Option Side Note" in Volution which can automatically populate a note of text. Does anyone know an HTML code I can use for the Color option so that the text notes would automatically change to let the customer know the lines and characters to include?
It sounds like you are looking for Volusion SmartMatch functionality, at least in part.
http://support.volusion.com/article/smart-match
I want to edit multiple lines and every "word" within that line. For example:
45 28 42 65
24 87 47 95
01 25 87 98
I want to select every whole number in all lines and put a "0x" before it so it would look like:
0x45 0x28 0x42 0x65
0x24 0x87 0x47 0x95
0x01 0x25 0x87 0x98
I know the Ctrl+shift+L to get cursors on each line, but how can I get the cursors in front of every number to mass edit all at once?
Highlight the lines and use:
Windows: Ctrl+Shift+L
Mac: Cmd ⌘+Shift+L
You can then move the cursor to your heart's content and edit all lines at once.
It's also called "Split into Lines" in the "Selection" menu.
Use multiple cursors and column selection.
In your case you just need to place the cursors at the beginning of each column containing the "words".
Linux and Windows
Click & drag to select column(s): Shift + RightMouseBtn
Add other column(s) to selection by click & drag: Ctrl + Shift + RightMouseBtn
Subtract column(s) from the selection: Alt + Shift + RightMouseBtn
Add individual cursors: Ctrl + LeftMouseBtn
Remove individual cursors: Alt + LeftMouseBtn
Mac
Click & drag to select column(s): Option⌥ + LeftMouseBtn
Add other column(s) to selection by click & drag: Option⌥ + LeftMouseBtn
Subtract column(s) from the selection: Cmd⌘ + Option⌥ + shift + LeftMouseBtn
Add individual cursors: Cmd⌘ + LeftMouseBtn
Remove individual cursors: Cmd⌘ + Option⌥ + shift + LeftMouseBtn
Then edit as needed. In your case, type 0, x.
You could also navigate as needed to the end or beginning of the words, select the words and surround with quotes or parenthesis, and so on.
References:
Column selection
Worked for me on OS X + Sublime build 3083:
OPTION (ALT) + select lines
I'm not sure it's possible "out of the box". And, unfortunately, I don't know an appropriate plugin either.
To solve the problem you suggested you could use regular expressions.
Cmd + F (Find)
Regexp: [^ ]+ (or \d+, or whatever you prefer)
Option + F (Find All)
Edit it
Hotkeys may vary depending on you OS and personal preferences (mine are for OS X).
I was facing the same problem on Linux,
what I did was to select all the content (ctrl-A) and then press ctrl+shift+L,
It gives you a cursor on each line and then you can add similar content to each column.
Also you can perform other operations like cut, copy and paste column wise.
PS :- If you want to select a rectangular set of data from text, you can also press shift and hold Right Mouse button and then select data in a rectangular fashion. Then press CTRL+SHIFT+L to get the cursor on each line.
Windows:
I prefer Alt+F3 to search a string and change all instances of search string at once.
http://www.sublimetext.com/docs/selection
On Windows, I prefer Ctrl + Alt + Down.
It selects the lines one by one and automatically starts the multi-line editor mode. It is a bit faster this way. If you have a lot of lines to edit then selecting the text and Ctrl + Shift + L is a better choice.
ctrl + shift + right-click
it works better that way
If you are looking to select the same word / value in multiple lines to then edit it, you can simply press "COMMAND + D" on the first entry and then keep pressing "D" to select the lines below
It's fine to manually select each number for a small set of numbers like in your example, but for larger collections you can do a regex search which will do the work for you.
Ctrl + F will open the search bar.
Regex searches are enabled by clicking the ".*" button on the far left.
Type in "\d+" to search for all occurrences of 1 or more digits. Clicking the "Find All" button will select each of these numbers separately.
Then you can use Ctrl + Shift + L to convert the selection into multiple cursors. From here you can do as you like.
Is there any plugin or shortcut to hide all except code section in sublime text 2?
I need to fold all except section at a time , Not fold one section at a time.
Thanks~
If you'll hover with the mouse over the line numbers you'll see arrows - clicking on any of them will fold/collapse the code
If you want to collapse/expand all - you can do so by going to edit->code folding and choose "fold all" or "unfold all":
In addition to the other answers it is also possible to fold based on level as well. So for example looking at the default key bindings for fold.
Searching for fold key bindings.
So for example a foldall, or folding level 1 would be to hold Ctrl followed by pressing the sequence k and then 1:
Or folding level 2 would be to hold Ctrl followed by pressing the sequence k and then 2:
Or unfolding all would be would be to hold Ctrl followed by pressing the sequence k and then 0 or in my defaults I also seem to have it bound to the letter j:
Warning.
Pressing Ctrl+k twice will remove a line or a count of lines.
But not really cause you can put them back one by one by Ctrl+u
One thing you can do is select the Except code bloc using a regular expression, for instance using except(.|\n)*?raise.* in your case. You can then select "Find all" in the search bar, then Edit->Code Folding -> Fold .
Windows shortcut : Ctrl-Shift-[
Mac shortcut: Cmd-Alt-[
All the Except bloc will then be collapsed.
I know this is an old question, but it still comes up high in search results and none of the answers quite do what the OP wanted.
select the code you don't want to be hidden
use "Selection" -> "Invert Selection" to select the code you do want to be hidden instead
use ctrl + shift + [ or Command + Option + ] to collapse the selection(s)
This will leave you with just the code you originally had selected visible.
Fold and UnFold function or class base only for MAC:
* Fold: command + K, command + 1
* UnFold: command + K, command + J
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.