multi-line selection in sublime text 2 - html

I want to select the text in all the alt tag and type in some identical text. I could be using the wrong key combinations. I've tried several combinations:
alt+left-click hold and drag the mouse,
ctrl+left-click hold and drag the mouse,
ctrl+alt+left-click hold and drag the mouse,
ctrl+alt+shift+left-click hold and drag the mouse,
ctrl+shift+L+left-click drag the mouse,
as well as swapping to "right-click+" with those combinations and here is the result:
That is not what I want.
The following is what I want to select:
In Sublime Text 2 using the MAC, you can hold down the option key and drag to make the selection. So usually in Windows, that means holding down the alt key. Holding down the alt key does not work. I checked out the key bindings in Sublime Text 2:
{ "keys": ["ctrl+alt+up"], "command": "select_lines", "args": {"forward": false} },
{ "keys": ["ctrl+alt+down"], "command": "select_lines", "args": {"forward": true} },
If the up key is the arrow up key, this doesn't work either. I've also tried ctrl+shift+L without success.
Thanks.

Try Middle Click + Drag or Shift + Right Click + Drag

Ok, I just kept trying and I stumbled upon the answer. I was going to delete the question since it was soon after I posted that I got it, but thought I would post for anyone who may have the same issue and have tried everything else others have posted.
Answer:
Left-click to place your cursor in the area you want to make a
multi-line selection, release left-click
After that selection, hold down the ctrl key
Left-click in the area you want to select in the line below (in my case it was the alt tag text)
Keep holding down the ctrl key, left-click each area
individually -- do not drag the mouse while holding ctrl key. Dragging selects everything from the starting point, not the individual area you want

Related

Sublime Text 2 - Drop Cursor From Multiple Line Selection

I've been using ST2 for a while now and am curious if there is a way to select multiple lines and drop the top or bottom selection.
For instance, if we selected four of them and then, drop the top cursor, I'd only have three selections. This would be very helpful when I'm doing multi-line edits with slightly different data.
You can open the ST console ctrl+` and write del view.sel()[0] to delete the first and del view.sel()[-1] to delete the last selection. You can obviously adapt the number to delete an other selection.
An alternative is to install MultiEditUtils with "selection fields", which is written to slightly modify single selections while working with multiple selections. Add the keybindings:
// default use of selection_fields
{ "keys": ["alt+d"], "command": "selection_fields" },
// add the current selections as a fields
{ "keys": ["alt+a"], "command": "selection_fields", "args": {"mode": "add"} },
// jump and remove current selection in selection_fields
{ "keys": ["ctrl+alt+d"], "command": "selection_fields",
"args": {"mode": "smart", "only_other": true} },
// cancel selection_fields and remove current selection
{ "keys": ["ctrl+alt+shift+d"], "command": "selection_fields",
"args": {"mode": "toggle", "only_other": true} },
Afterwards you can press alt+d to change the selections to "fields". Now move with tab or shift+tab to the selection you want to remove. Press ctrl+alt+d to remove the selection and jump to the next field. Press ctrl+alt+shift+d to remove the selection and convert all other fields to selections. Press escape to convert all fields to selections.
This is possible using subtractive drag select. On Windows and Linux, hold down Alt (on OS X, hold down ⌘Alt) while holding down mouse button 1 (typically the left mouse button, for right-handed users) and dragging across the cursor, either from left to right or right to left - the drag needs to start in the editing area, though, not the gutter to the left of the text where the line numbers are. Subtractive select also works when selecting words, lines, or columns - just hold down Alt or ⌘Alt while double- or triple-clicking, or selecting columns.
For a full list of available mouse combinations, go to your Packages folder, the one opened when selecting Preferences → Browse Packages…, go to the Default folder, and open Default (YourOSHere).sublime-mousemap (YourOSHere being one of Windows, Linux, or OSX) with JSON syntax highlighting. If you're using Sublime Text 3 (which I very strongly recommend upgrading to), you'll need to install PackageResourceViewer, as the files in Default are now in a .sublime-package archive. Once installed, select PackageResourceViewer: Open Resource, scroll down to Default, then select the .sublime-mousemap file that corresponds to your operating system.

How to add more selections or less selections by keys

I'm using Mac, SublimeText2
When I used the mouse to click got_value, the words equal to got_value will be highlighted,
Then I press cmd+D , only the first 2 got_value were selected,
How could I make more got_values to be selected ? (by keyboard but not mouse click)
Thanks
Keep pressing cmd+d to select more instances.
Press cmd+u to unselect the last instance.
Or, to highlight them all
ctrl+cmd+g

Pin search bar to Sublime Text 2

Is it possible to pin the search bar/search&replace bar (Ctrl+F or Ctrl+H) to the window. Because now, if I press Esc, my search bar disappears.
For example when having search bar + multi-line cursors active and when I want to deactivate multi-line cursors using my keyboard (I know a mouse click deactivates multi-line cursors too), I click on Esc. But Esc deactivates both (search bar + multi-line cursors)
I hope you understand what I mean.
Edit:
There is one thing that I'm asking myself a lot of times. I can make the search bar active by doing Ctrl + F, but after I search I want to go back to edit my file (I want to go out of my search bar and go to the place where I found what I searched) This is again possible with mouse click but i want to do it with my keyboard. (something like tab out of the search field). Anyone who knows there is a key binding for this?
--> I found I can use Alt+Enter for this but it selects all occurences. to disable the selections I just move with my arrow keys...
If you're using ST2 you can just edit/remove default key binding (as I remember) for this:
{ "keys": ["escape"], "command": "hide_panel", "args": {"cancel": true},
"context":
[
{ "key": "panel_visible", "operator": "equal", "operand": true }
]
},
ST3 doesn't allow you to edit default bindings so I was able only to reorder Esc button behavior when panel is visible: first press deactivates multi-line cursors, and the second press hides a search panel. If no multi-line cursors active then Esc only hides a search panel.
Try to add these lines to the User's key bindings file:
{ "keys": ["escape"], "command": "single_selection", "context":
[
{ "key": "num_selections", "operator": "not_equal", "operand": 1 }
]
},
Hope this will help.
EDIT: Fixed lines to add

How do you cycle through multiple cursors in Sublime Text like you would with placeholders?

Is there a way to tab through multiple cursors like you can with placeholders?
Having those cursors placed you would:
type "index"
tab
type "products"
tab
…
You could create bookmarks with the multiple cursors (ctrl+f2 or cmd+f2 by default I think). Then, you could return to a single cursor (escape). After you enter the content on a particular line, you could then move to the next bookmark (f2 by default). Of course, those are with the default keybindings. You can always rebind them to something more comfortable than f2.
There is a plugin for that and more. https://packagecontrol.io/packages/MultiEditUtils
You can add this line to your User Keybindings for custom hotkey:
{ "keys": ["alt+d"], "command": "selection_fields" },

Sublime text 2 - zen coding change key binding

I need the TAB to switch between highlights in my css snippets.
I'm using css snippets and #FFF+tab =>
I want to change zen-coding key biding from tab to CTRL+, (comma)
I've changed (the last line in default.sublime-keymap) from "tab" to "ctrl+,"
The new command works (ctrl+,) but I still have the tab transforming #FFF to a div.
HOW to completely remove the tab from zen-coding without affecting the TAB from Sublime?
Thanks
(I don't know what I've did wrong the first time but now it works)
so do change the key biding to zen-coding in sublime text 2 just change the last line in Preference > ZenCoding > Bidings > default.sublime-keymap
from
"keys": ["tab"]
to
"keys": ["ctrl+,"]
(or whatever new key you want)