I'm using Sublime Text 3 as my code editor. I would like some help/explanation as to why the indentation misbehaves so much:
Is there any way to force the indentation when you open a file (I like it set to tabs, tabs_size = 4)?
Whenever I save a file, it automatically reverts the indentation to spaces... How would one go about avoiding that?
Any help is appreciated, I've been pulling my hair because of these tiny issues.
P.S.: Here are my settings
{
"color_scheme": "Packages/User/base16-ocean.dark (SL).tmTheme",
"detect_indentation": false,
"tab_size": 4,
"translate_tabs_to_spaces": false,
"font_face": "Source Code Pro",
"font_size": 15.0,
"ignored_packages":
[
"SideBarEnhancements",
"Vintage"
],
"theme": "Spacegray.sublime-theme",
"word_wrap": true
}
Related
Does anyone know how to delete a word going to the end of the line (right) in the VSCode Terminal (not editor)?
This works fine doing shift+ctrl+rightArrow in the Editor and I've mapped the same key-binding in iterm2 which labels this behavior I'm looking for as "Move End of Selection Right By Word".
I would love to shift+ctrl+arrow in the TERMINAL to select my text like I can in iterm2.
I've searched and searched and have come up short. I'm using iterm.app in VSCode as well as setting my defaultProfile.osx to zsh.
Try these keybindings that I know work in Git Bash (in keybindings.json):
{
"key": "alt+delete", // whatever keybinding you want
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u001b\u007f" // delete from cursor to word left start
},
"when": "terminalFocus"
},
{
"key": "ctrl+delete",
"command": "workbench.action.terminal.sendSequence",
"args": {
"text": "\u001bd" // delete from cursor to word end right
},
"when": "terminalFocus"
}
These are sending controls sequences to the terminal. I don't think there is any built-in commands to do this.
I'd like the user of my xlsx spreadsheet to edit some parts of a sheet but not the most of it. Or in other words, I'd like only some parts of the sheet to be protected.
I learned how to protect the sheet using rubyXL with the code below:
sheetProtection = RubyXL::WorksheetProtection.new(
password: hashedPass,
sheet: true,
objects: true,
scenarios: true,
format_cells: true,
format_columns: true,
insert_columns: true,
delete_columns: true,
insert_rows: true,
delete_rows: true
);
wsData = workbook['data'];
wsData.sheet_protection = sheetProtection;
Say, I'd like the user to only edit the cell range C2:C13 of the said sheet.
I can't find the syntax on how to do that from the documentation of the rubyXL nor how to use that documentation (please forgive my ignorance). I'm at a loss when I click any link on the side of that page, because for me, it seems the only friendly one is the main page. Google is not helping. In the above code, I don't know how they get the sheet_protection property of the worksheet as available for use.
In the closest clue I found, I learned that "unprotection" of a cell can be achieved by a cell style. So I tried creating a style and putting that one in a cell, but that one too proved to be difficult due to lack of guides.
In the cell_style.rb of the github repo, I found something about Protection and CellStyle classes.
unprotected = RubyXL::Protection.new(
locked: false,
hidden: false
);
unprotecStyle = RubyXL::CellStyle.new(
name: 'unprotected style'
);
I can't find in the docs how to put them together, or even apply a style on a cell:
wsData[1][2].cell_style = unprotecStyle;
# undefined method `cell_style=' for #<RubyXL::Cell(1,2): "cell-content", datatype="str", style_index=8>
I'm not even sure if I'm on the right track. Please help.
Perhaps you figured this out already, but this worked for me...
Given a worksheet and a cell, I did:
worksheet.
workbook.
cell_xfs[cell.style_index || 0].
protection = RubyXL::Protection.new(
locked: false,
hidden: false
)
Then I did:
worksheet.sheet_protection = RubyXL::WorksheetProtection.new(
sheet: true,
objects: true,
scenarios: true,
format_cells: true,
format_columns: true,
insert_columns: true,
delete_columns: true,
insert_rows: true,
delete_rows: true
)
Which protected the entire worksheet except for the cell.
Rather than taking my hand of the mouse to use Ctrl + Shift + /, I'd like to be able to comment code by highlighting it, and then while keeping the left mouse button held down, simultaneously right click and have it comment out - though I don't know if that's possible with Sublime Text keybinds.
If not, I'll just use a custom keyboard shortcut, but I'd prefer the mouse method.
You can customize mousebinds by creating a file named Default (Windows).sublime-mousemap, Default (OSX).sublime-mousemap, Default (Linux).sublime-mousemap or (for any OS) Default.sublime-mousemap in your settings folder \Packages\User and then creating your custom bind inside that file
You can read more here (it's actually about keybinds but the process of creating mousebinds is the same.)
I came up with something similar to what you are trying to achieve but could not bind mouse1 as modifier so the snippet below is working different.
After you've made a selection, click and hold right mouse button and then click left mouse button to toggle comment block on selected area.
[
{
"button": "button1", "count": 1, "modifiers": ["button2"],
"command": "toggle_comment", "args": {"block": true},
"press_command": "drag_select_callback"
}
]
This might be annoying if you comment something by accident, so you can change click to double click, by changing count value to 2 or 3 for triple click etc.
Block comment is defined by {"block": true}, if you would like line comments just change it to false
[
{
"button": "button1", "count": 1, "modifiers": ["button2"],
"command": "toggle_comment", "args": {"block": false},
"press_command": "drag_select_callback"
}
]
I already have the following setting in Preferences -> Settings - User
{
"translate_tabs_to_spaces": true,
"tabSize":2,
"detect_indentation": false
}
However opening a new file and hitting tab still indents 4 spaces. How can I make Sublime indent 2 spaces on new files?
It appears you didn't correctly spell tab size :
// Settings in here override those in "Default/Preferences.sublime-settings",
// and are overridden in turn by file type specific settings.
{
"tab_size": 2,
"translate_tabs_to_spaces": true
}
I tried this on Sublime and it works like a charm.
see here : http://www.sublimetext.com/docs/2/indentation.html
One very long standing habit I have with my IDE of many years is that the CTRL (or command) + Click selects a full word. It is the equivalent of doing a double click on a word currently in ST2. I am hoping to be able to restore this ability in ST2. Would I go about it with a key-binding or a plugin?
If you create a sublime-text-2/Packages/User/Default (Linux).sublime-mousemap file (assuming you are on Linux) and put this in it (If the file is already there then put it at the end of the file within the square brackets already present):
[
{
"button": "button1", "count": 1, "modifiers": ["ctrl"],
"press_command": "drag_select",
"press_args": {"by": "words"}
}
]
It will override the standard Ctrl+Click behaviour, and do what you want. However the default Ctrl+Click behaviour is very cool - allowing for simultaneous multiple selections and cursors (try Ctrl+Clicking in different places in a file), so you may want to reassign that functionality elsewhere. If you wanted to change the multi-select feature to Ctrl+Alt+click, you can do this by also adding, inside the square brackets:
{
"button": "button1", "count": 1, "modifiers": ["ctrl", "alt"],
"press_command": "drag_select",
"press_args": {"additive": true}
}
It Works for st3, i think works in st2
Linux - create "Default (Linux).sublime-mousemap" in ~/.config/sublime-text-3/Packages/User
Mac - create "Default (OSX).sublime-mousemap" in ~/Library/Application Support/Sublime Text 3/Packages/User
Win - create "Default (Windows).sublime-mousemap" in %appdata%\Sublime Text 3\Packages\User
[
{
"button": "button1",
"count": 1,
"modifiers": ["ctrl"],
"press_command": "drag_select",
"command": "goto_definition"
}
]