Vintage mode: moving farthest left or right within a wrapped line - sublimetext2

I am in the process of switching to Vintage mode, and I would like to turn off my arrow keys. However, what's stopping me is not knowing how to move farthest left or right within a wrapped line. For example, within a markdown file paragraph.
I achieve this with command + arrow left or arrow right, depending on where I need the cursor. What's the equivalent of this in vintage mode?
Just to be explicitly clear, I am not trying to get to the beginning or end of the entire line, I am trying to move the cursor to the beginning or end of the wrapped it is currently sitting in.
Edit
Adding an image to illustrate what I am trying to do. The arrows indicate where I would want the cursor to jump to with the proper left or right keyboard shortcut.

Go to you Key Binding - User
Add following key bindings
,{ "keys": ["super+0"], "command": "move_to", "args": {"to": "eol", "extend": false} }
,{ "keys": ["super+1"], "command": "move_to", "args": {"to": "bol", "extend": false} }
Save and you can use command+0 / command+1 to go to end/start of the line.

While in command mode, 0 for beginning of line and $ for end of line.

Related

Sublime Text 3 insert tab character manually

When using Sublime Text 3, most of my files are set to be indented using spaces. However I sometimes wish to insert a literal tab. When I was using Vim I'd use Ctrl+v Tab but that doesn't work with Sublime Text 3.
I've been searching and searching and cannot find anything. Please help!
There is a default key binding of Shift+Tab to insert a raw tab character into the document, although in certain contextual cases (such as when expanding a snippet) it takes on other functions instead.
However, Indent Using Spaces is controlled by the following setting:
// Set to true to insert spaces when tab is pressed
"translate_tabs_to_spaces": false,
As seen here it defaults to false, but when you have Indent using spaces turned on, it's set to true. As the comment alludes to, when this setting is set to true any attempt to insert a raw tab character gets converted to some number of spaces instead.
As a result, even the official key binding does not insert a raw tab in this case.
Depending on how often you care to insert a literal tab you can work around this by temporarily turning that setting on and off, but this is far from ideal, even when the setting is toggled from the menu in the status bar.
Since Sublime is so customizable, we can automate it into doing that work for us.
To start with, create a file with the following contents and save it in your User package as literal_tab.sublime-macro (use Preferences > Browse Packages... to find your User package if you're not sure where it is):
[
{ "command": "toggle_setting", "args": { "setting": "translate_tabs_to_spaces" } },
{ "command": "insert", "args": { "characters": "\t" } },
{ "command": "toggle_setting", "args": { "setting": "translate_tabs_to_spaces" } }
]
Then, add the following two key bindings to your user bindings (Preferences > Key Bindings in the menu; if there are multiple options, choose User and not Default):
{
"keys": ["ctrl+k","tab"],
"command": "insert",
"args": {
"characters": "\t"
},
"context":
[
{ "key": "setting.translate_tabs_to_spaces", "operator": "equal", "operand": false }
]
},
{
"keys": ["ctrl+k","tab"],
"command": "run_macro_file",
"args": {
"file": "Packages/User/literal_tab.sublime-macro"
},
"context":
[
{ "key": "setting.translate_tabs_to_spaces", "operator": "equal", "operand": true }
]
}
Both bindings include a context that causes it to trigger or not based on the value of the translate_tabs_to_spaces setting, so at any given time only one of them is actually in effect and the other one is automatically disabled.
The first binding is for the case when the setting is turned off, in which case it just needs to insert a tab character and it's done. The second case instead runs our custom macro from above, which turns the setting off, inserts the tab, and then turns the setting on again.
In theory you really only need the second one if you always leave the indent setting turned on, but due to the Principle of Least Surprise it's a good idea to set it up to work regardless of the setting.
Naturally you can use any key stroke that you want (I'm also used to this one from vim), and the name of the macro file doesn't matter as long as it has the correct extension and it matches what the binding tries to execute.
Note: Although you mentioned Sublime Text 3 in your question, you tagged Sublime Text 2 as well, so for completeness I'll also note that the information and solution presented here applies to both versions equally.

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.

multi-line selection in sublime text 2

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

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

Quick add previous in sublime text 2

Is there a quick add previous in sublime text 2 like the quick add next(ctrl+d)?
Relevant lines in keymap
{ "keys": ["ctrl+d"], "command": "find_under_expand" },
{ "keys": ["ctrl+k", "ctrl+d"], "command": "find_under_expand_skip" },
I tried changing that find_under_expand to find_over_expand but it doesn't work.
You can use ShiftF3 to move the selection to the previous occurrence, and once you've reached the start of where you want to make multiple selections you can use CtrlD and CtrlK,CtrlD, but to my knowledge there is no way to make multiple selections in reverse without writing a specialized plugin.