How to disable multiple cursors in sublime2? - sublimetext2

How do I disable the multiple cursor feature in Sublime text 2? I googled, but found only videos on how to use it, not how to not use it..

If you have multiple cursors just press ESC to return to a single one.
#starwed - how did you accidentally enable it?
Open your preferences/keymap and
search for split_selection_into_lines, find_under_expand and find_under_expand_skip (these are the main methods to enable multiple cursors)
then assign a key combination that you are unlikely to press by accident.

According to this link on sublime forum, you can't directly but you can disable the keys that trigger it.
ctrl-shift-l (that's el)
and ctrl-left click
To disable ctrl-shift-l I don't know whether it's possible in the user file(the keymap/bindings file in the user directory), but you can in the default bindings file(the keymap/bindings file in the default directory) .. either removing the line or rewriting it e.g. adding +u
preferences..packages
C:\Users\user\AppData\Roaming\Sublime Text 2\Packages\Default\Default (Windows).sublime-keymap
Change this line adding a +u so it'd get triggered by ctrl+shift+l+u rather than ctrl+shift+l. I doubt you would accidentally do ctrl+shift+l+u or at least not as often as you might accidentally do ctrl+shift+l !
{ "keys": ["ctrl+shift+l+u"], "command": "split_selection_into_lines" },
Also, to disable the ctrl-left click, that link suggests doing this, and I tried it and it works. (though I I like the feature and the binding!)
Preferences..browse packages..User
C:\Users\user\AppData\Roaming\Sublime Text 2\Packages\user
Create this file there, in the form Default (<your OS>).sublime-mousemap
Default (Windows).sublime-mousemap
it corresponds to the file of the same name in the default directory. but is in the user directory and takes precedence, overwriting settings in the default directory one.
(settings in the user directory one will take precedence and overwrite settings in the one in the Default directory) C:\Users\user\AppData\Roaming\Sublime Text 2\Packages\Default (Windows).sublime-mousemap )
So, in C:\Users\user\AppData\Roaming\Sublime Text 2\Packages\user\Default (Windows).sublime-mousemap
paste
[
{
"button": "button1", "count": 1, "modifiers": ["ctrl"],
"press_command": "drag_select"
}
]
that disables ctrl-left click trigger of multiple selection.
Note- I use ctrl and left click, and don't recall if I have triggered it accidentally, but perhaps your thumb is touching the touchpad sometimes(making a left click) when you hit ctrl.

in your config Preferences -> Settings - User add line "multi_select": false
In the end your config should look smth like this:
{
"color_scheme": "Packages/Color Scheme - Default/railscasts.tmTheme",
"detect_indentation": false,
"font_face": "Droid Sans Mono",
"font_size": 14,
"ignored_packages":
[
"Vintage"
],
"scroll_past_end": false,
"tab_size": 2,
"run_on_save": true,
"save_on_focus_lost": true,
"translate_tabs_to_spaces": true,
"trim_trailing_white_space_on_save": true,
"word_wrap": true,
"multi_select": false
}
I was looking how to disable that feature myself... found nothing, and just thought to play around with config... on linux it worked!

Related

How to have VS Code format HTML code adding white line space when hit enter

What should I change in VS Code so that when I create a label and then hit the enter key, the editor automatically creates a blank line for me and adds tab stops like in the following image?
https://code.visualstudio.com/assets/docs/languages/html/auto-close1.gif
I have this settings in my editor settings.json:
"editor.autoClosingBrackets": "always",
"editor.autoSurround": "brackets",
Currently what I need to do is hit the enter key twice and then manually tab.
I found the solution by copying all the default options from the settings.json file and comparing with the ones I already have set. The value to change was:
"editor.autoIndent": "keep",
and it should be:
"editor.autoIndent": "full",

How do I go to the end of a line in VS code without using the mouse or some key combinations?

I am using VS Code to write some HTML. I noticed that the IDE will auto-insert some code for me. For example, if I want a <p> tag, VS Code will create <p></p> for me and the cursor will land in the middle (between the opening and closing paragraph tags). However, when I am done typing the content inside the <p> tags, typically, I use my mouse or the directional right-arrow to move to the end. Is there a way to not move my fingers from the typing positions (e.g. fdsa and jkl;) to go to the end of the line or tag, or would I always have to use the mouse or directional pad?
I find IDEs like what JetBrains provide do not have this limitation for certain languages. For example, in Python, if I want to print something using PyCharm, I can type (the closing single quote and right parenthesis are auto-added)
print('')
My cursor will land inside the single quotes. To simply get outside the closing parenthesis, I simply type in ' followed by ) and the IDE is smart enough to know to not place the single quote and closing parenthesis there (it's like using the right arrow twice to get outside the print statement).
WebStorm, like VS Code, has the "problem" when dealing with HTML. If I am inside an opening and closing <p> tag, and right next to the closing one </p>, simply typing <, /, p, > will not land me outside (as with Python and PyCharm). On Windows, I can press the End key or on Mac I can press fn+right to get to the end; but that requires breaking the flow and continuity of my hands in the typing positions (eyes have to be redirected too).
Any tips on how to be a more productive coder using VS Code or other modern IDEs with HTML? Are there plugins that we may use to address this problem?
You can paste this code in your keybindings.json file in vs code
ctrl+RightArrow ....>>> for Move cursor to Line end
ctrl+LeftArrow ....>>> for Move cursor to Line start
alt+RightArrow .....>>> for moving cursor word by word
alt+LeftArrow ....>>> for moving cursor word by word
Just paste this code into your keybindings.json in vs code
[
{
"key": "alt+right",
"command": "cursorWordEndRight",
"when": "textInputFocus && !accessibilityModeEnabled"
},
{
"key": "alt+left",
"command": "cursorWordEndLeft",
"when": "textInputFocus && !accessibilityModeEnabled"
},
{
"key": "ctrl+right",
"command": "cursorLineEnd"
},
{
"key": "ctrl+left",
"command": "cursorLineStart"
},
]
Make sure to adjust commas and brackets, if there is already some code.
Simply go look it up or change it in your key binding settings:
File > Preferences > Keyboard shortcuts
It's named cursorLineEnd.
Same can be done for cursorLineStart of course.
Interfering other shortcuts can be changed or deleted as well in that menu.
I often just use <CTRL> + → (right arrow) a few times to quickly navigate past words and code blocks. It won't immediately get you to the end but if there isn't a ton of code after your current cursor location, a few quick uses of this keystroke can be faster than lifting your hands and checking with eyes to find the key.
Depending on what your keyboard layout is, this could be faster. Personally, if it's a big issue, I would second other posters here and add a custom keybind / hotkey to a lesser-used key nearby.
//Begin CAVEAT
I'm not mentioning just using the <END> key here as a solution purposefully, since you indicated that using that using keys too far from home row broke your flow. Depending on my keyboard layout, that is often the fastest option by far, however my current keyboard makes that a non-starter.
Part of the issue here is that people's experience is so different based on what keyboard they're using, as well as hand size and dexterity. YMMV with any solutions we mention that isn't a custom keybind.
//END CAVEAT
Cmd + Right
This will go to the end of you current line.
Tips:
Hold down shift to start a selection
Use Alt or Ctrl instead of Cmd to change the distance the cursor travels
If you want to go to the end of a line, just press the End button on the keyboard, and press Home to go to start of a line.
Change the key binding for cursor down to Shift + Space. I didn't remap right Arrow for reasons I'll explain shortly, but I could have easily done that as well.
When I code, I like to use indented formatting. So, when I type <p> and </p> is automatically generated, I go one step further and press ENTER. By default, that causes </p> to move to the same indention level as <p> on the line below my cursor, and puts my cursor on an indented line below <p>. Gif for reference:
Shortcut to make an indented block:
That leaves my fingers basically on the home keys, because when I'm done in that level, I'll press Shift + Space to go to the line below, where the ending tag will be, and then I can press ENTER a couple times as normal and create a new tag or whatever else I'll be adding to the file.
If you would like to set up your key bindings like mine, or do something slightly different, here is what I did:
Ctrl + K Ctrl + S (to open key bindings)
Search for "cursorDown"
Highlight the row and press ENTER
Press Shift + Space
I'm not sure which OS you specifically use being that you mentioned but an OS agnostic approach is to create your own keybind / key chord (sequence).
A key chord is essentially a way to use another 'layer' of key shortcuts, if you use your imagination for lingo. To illustrate: consider CTRL + S is a keyboard shortcut. Now consider CRTL + K chord CTRL + S, which is a completely different shortcut even though you use the same sequence.
Consider an edit/insert mode
I don't use vim, nor have I ever tried, but I really find value in the idea of having different 'modes', one visual one for insert and edit. Personally, I have elected CTRL + E to be my chord sequence for 'edit mode'. Now, every single key and sequence of keys becomes a brand new possability. Why CTRL + E? Well 'e' for edit, naturally, but also because it is default duplicate; for whatever reason vscode identifies this shortcut to be the same as CTRL + P by default.
I then use $ to go to the end of the line and ^ to the beginning, arbitrarily because of regex, but the point is you can create your own according to your own preference, which appears to be that of the home row. So if you elect to go this approach you can use j if you want. If you were to argue this is too much user input for a single action, consider the position of using a PC at home and a mac at work, as I do, you would already be comfortable with your settings and not need to 're-learn' shortcuts.
This answer uses an approach that affords you the creative freedom to define what a 'productive coder' looks like for you, provides a different approach to going to the end of line while maintaining your home row position, and hopefully demonstrates to any new vscoders that you are not bound to just using the native CTRL + K sequence as the chord identifier.
Regardless, re:
without using ... some key combinations?
That's unavoidable, I think, unless you choose to remap normal typing keys for this purpose
If you like to stick to the home row and do not want to use arrow keys,
you can customize your keyboard shortcuts.
paste the below code to your keybindings.json file in vs code.
Feel free to customize these shortcuts by changing key combinations.
,{
"key": "alt+l",
"command": "cursorEnd",
"when": "editorTextFocus"
},
{
"key": "alt+j",
"command": "cursorHome",
"when": "editorTextFocus"
}
For me it is Fn + -> (Right Arrow Key) that's the quickest possible approach
No need to do these messy things, just use your keyboard's home key and end key
Press the home key to go to the beginning of the line
Press the end key to go to the end of the line

Sublime Text 3 - Hitting tab doesn't add space, instead makes text lower case

If I were to type the following:
TEST
Then hit TAB, the code would now look like this:
test
I don't know what happened, but tab is not indenting anymore and changes the text on the current line to lowercase.
Any idea how to restore the TAB function?
One possible reason for this in the general case is that you have installed a third party package that's stolen the Tab key binding in order to perform it's own action, which in this case would be turning the prior word lower case.
This will be the case if this behaviour holds true for any word that you happen to press Tab after. In that case the solution would be to find the package that's doing this and disable or reconfigure it.
In your case I think the more likely cause for this is that in the file you're currently editing the word TEST appears, and you have the following setting turned on:
// When enabled, pressing tab will insert the best matching completion.
// When disabled, tab will only trigger snippets or insert a tab.
// Shift+tab can be used to insert an explicit tab when tab_completion is
// enabled.
"tab_completion": true,
When the setting is set to true (which is the default), pressing Tab will attempt to perform a tab completion, which considers not only snippets and completions but also words in the current buffer as well.
In that case, if you were to enter the word test and press Tab at a point where the word TEST also appears in the buffer, it's considered a potential completion and will become the replacement.
If this is the problem you would see similar behaviour by just entering t and pressing Tab, which would cycle through all of the T words in the buffer as possible completions.
Assuming this is what's happening to you, one of the following should fix the problem for you:
Set tab_completion to false in your preferences; this will disable the feature entirely everywhere
Set tab_completion to false only in the settings of the specific file type that you're having the problem in; that would leave the feature enabled in the general case but stop it from occurring in the files that you don't want it to occur in.
Use Shift+Tab instead; that key sequence will do what Tab normally does and insert a tab character even if Tab would try to do a completion.
For #3 to work, make sure that you have this setting set as follows:
// By default, shift+tab will only unindent if the selection spans
// multiple lines. When pressing shift+tab at other times, it'll insert a
// tab character - this allows tabs to be inserted when tab_completion is
// enabled. Set this to true to make shift+tab always unindent, instead of
// inserting tabs.
"shift_tab_unindent": false,
The default for this value is false, in which case as the comment mentions the binding will perform a tab unless you have multiple lines selected in which case it unindents instead.

How to disable Auto Complete in Sublime Text (2&3)

I understand there are a few questions surrounding the auto_complete function in Sublime Text.
However, I have not been able to disable the auto_complete function in the Sublime Text settings (I've tried both Sublime Text 2&3). I just get the "Error trying to parse settings: Unexpected trailing characters in Packages/User/Preferences.sublime-settings:5:1" error when inputting the {"auto_complete": false,} command in user settings.
Would love to turn off the setting, but can't find a way to. Any help much appreciated!
Put , after font-size:17 like:
{
"font_size":17, //note a comma here after 17
"auto_complete": false,
}
This is the first result that pops up when Googling "Sublime Text disable autocomplete", and none of the answers answered my question completely, so I'd just like to add to the existing answers that if you are setting auto_complete to false and still having problems with Sublime Text auto-closing parentheses and brackets, then you also need to set auto_match_enabled to false. This should solve the problem. So as a whole, here is what I have:
{
"auto_complete": false,
"auto_complete_commit_on_tab": false,
"auto_close_tags":false,
"auto_match_enabled": false
}
There are two options:
1: In Preference --> User, Check if TernJS plugin is Installed. If Yes, Unistall it from your editor (i.e. Sublime Text Editor).
2: In Preferences --> User, check for the auto_complete and change it to false
"auto_complete": false,
Restart Your Editor(Sublime Text)
This should be the option.
{
"auto_close_tags":false
}
My solution to this problem was to change "auto_complete_commit_on_tab" from true
to false. This way you aren't turning off autocomplete altogether, but the autocompletion is ignored unless you hit the tab key.
In preferences, user settings, add:
{
"auto_complete_commit_on_tab": false
}
I came here looking for a Python-related solution, where autocompletion worked well for variable names etc. but was quite slow for methods etc.
So, to disable Python syntax autocomplete:
open the command palette with ctrl + shift + P
enter Package Control: Remove Package and select it
enter Jedi and remove the Jedi autocomplete package

How do you default to Soft Tabs while programming in Textmate?

My "Soft Tabs" setting in TextMate is not sticky. After I restart TextMate, I often have to set the option again for the same file. How can I make this setting the sticky default across all files?
For Textmate 1
After doing some research, I found that you can set TextMate 1 to default to using Soft tabs.
In the "Shell Variables" area of the Advanced preferences pane, add a new entry with the name TM_SOFT_TABS and a value of YES.
From that point on, TextMate should default to Soft tabs, though for at least one or two languages, I had to specify the number of tabs. After I did that, it seemed to stick for everything I did.
For Textmate 2
To set the options in TextMate 2 add following settings to your ~/.tm_properties file:
softWrap = true
tabSize = 4
softTabs = true
Check these links for more information:
FAQ: https://github.com/textmate/textmate/wiki/FAQ
Settings: http://wiki.macromates.com/Reference/Settings
From the documentation:
4.11 Using Spaces Instead of Tabs
TextMate can use spaces instead of tab
characters. This is done by clicking
the “Tab Size” pop-up in the status
bar and enabling Soft Tabs.
This setting will only affect the
current language and all languages
with a common root that do not have
the option set yet. The same applies
to the state of spell checking, soft
wrap and the actual tab size.
When soft tabs are enabled, TextMate
will for the most part act exactly as
if you were using hard tabs but the
document does indeed contain spaces.
Looks like Textmate sets it for the current language, but I think Textmate analyzes the files you open and adjust its settings to match the files. You can convert the tabs in your files to spaces and vice versa in the "Text" menu.
You don't need anything special. You just need to adjust your Python bundle.
Go into the 'bundle editor' and find Python. Open its caret, and scroll down and find the 'miscellaneous' preferences. It should read something like:
{ decreaseIndentPattern = '^\s*(elif|else|except|finally)\b.*:';
increaseIndentPattern = '^\s*(class|def|elif|else|except|finally|for|if|try|with|while)\b.*:\s*$';
shellVariables = (
{ name = 'TM_COMMENT_START';
value = '# ';
},
{ name = 'TM_LINE_TERMINATOR';
value = ':';
},
);
}
These are the environmental variables. What you want is the environmental variable TM_SOFT_TABS to be set to 'YES'. Simple enough, Just insert a new assignment like so:
{ name = 'TM_SOFT_TABS';
value = 'YES';
},
...and voilà! Your tabs will be soft every time you use Textmate in Python mode.
For all the different enviornmental variables you can set, check out the manual here:
http://manual.macromates.com/en/environment_variables.html
... in addition to #Ivan Sviatenko's answer
For Textmate 2, language specific softTabs default
edit ~/.tm_properties, for example:
# Default editing configuration
#
tabSize = 2
softTabs = true
softWrap = true
# Defaults for c
#
[ source.c ]
softTabs = true
tabSize = 8
# Defaults for python
#
[ source.python ]
softTabs = true
tabSize = 4
There is also a drop down menu at the bottom of TextMate, which allows you to set your Tab Size value and whether to use Soft Tabs, and it is sticky.
Create an alias icon for TextMate on the desktop.
Drag the file to be opened to the icon.
The file should now be opened in TextMate.
Set the soft tab with the status bar options.
Close TextMate.
Repeat step 2 - 5 for each file type you want the soft tab settings to be remembered.
Every time you want to open a file type with TextMate drag that file to that desktop icon.
Do not open more than one file type at the same time, the second file type opened will get its soft tab settings erased.
This is the only way I've been able to get a consistant behavior on the soft tabs settings.
I found a popular TextMate plugin called "TabMate," which has solved this issue for me. While it requires me to add a tabline to every file, TextMate adjusts my tab settings to be whatever is described in the tabline.
Also, technically gs's answer above should work but for some reason it isn't working for me and I found no other way to set SoftTabs is the default setting for ALL languages forever.
TabMate: http://konstochvanligasaker.se/tabmate/