How can I configure sublime to always use 4 spaces? - sublimetext

I know that sublime has the following space-related settings:
Preferences.sublime-settings
{
"tab_size": 4,
"translate_tabs_to_spaces": true,
"use_tab_stops": false
}
I think this means:
tab_size: When I press Tab I get 4 spaces (or a tab length of 4, depending on wheather it makes tabs or spaces)
translate_tabs_to_spaces: When I save a document it will translate tabs to spaces
use_tab_stops: (only relevant for spaces) Sublime will not simply enter 4 spaces, but will eventually add less spaces to get to the next tab position.
But although I have this configuration, I see all the time:
My project.sublime-project has:
...
"settings":
{
"tab_size": 4,
"translate_tabs_to_spaces": true,
"use_tab_stops": true
}
...
How can I tell sublime to always use 4 spaces? (except for Makefiles, where it has to use tabs. But the focus of thes question is on 4, not on spaces)
I have Linux Mint 16 Petra and Sublime Text build 3059

The problem you have stated is happening because your current file has indentation of 2 spaces and ST is using the auto detected indention as it has the highest priority in all Preferences1.
Add below line to Preferences"detect_indentation": falseSo that it won't change the indentation setting automatically.

Related

vscode-go input tabs of size 4 instead 8

I have Visual Studio Code Insiders installed. Basically I've installed Go extension from Microsoft and written simple hello world app. Now I always use spaces to indent my code, but I saw that it changed to tabs of size 4. So I thought: yay, what a nice extension, now I can start to write my code.
Then I remembered, that the default code indent from gofmt should be 8 as tabs. And I checked. gofmt main.go indeed outputs my code with tabs of size 8. But vscode keeps doing tabs of size 4. I thought maybe it doesn't even call gofmt but when I go RPM->Format document with - it actually does. But still, tabs of size 4. What am I doing wrong in this scenario?
"editor.renderWhitespace": "all",
"editor.fontFamily": "Hack",
"editor.fontSize": 12,
"editor.minimap.enabled": false,
"editor.fontLigatures": true,
"workbench.editor.enablePreview": false,
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"editor.cursorSmoothCaretAnimation": true,
"editor.detectIndentation": false
Those my only editor settings and I dont have any custom settings regarding Go extension
go fmt uses tab characters ("\t") to indent the beginning of a line. How a tab is displayed (tab width) is up to your text editor or IDE. I have Tab Width set to 4 in my text editors. My terminal program uses a tab width of 8.
For example, for xed,
Editor Preferences
Tabs
Use the Tab width spin box to specify the width of the space that xed
inserts when you press the Tab key.
Select the Insert spaces instead of tabs option to specify that xed
inserts spaces instead of a tab character when you press the Tab key.

soft tabs showing up as hard tabs, spaces converted to hard tabs

I have soft tabs enabled, but not only is the editor putting actual tabs in instead of spaces, if I type [space][space], it converts it to a tab. I've read that the editor tries to read existing files to guess your settings (I have Autodetect turned off if that matters), so I tried with a new file. Here is the relevant section of my settings file (which I edited through the GUI):
"ace": {
"#guessTabSize": false,
"#newLineMode": "unix",
"#tabSize": 2,
"#useSoftTabs": true
},
When I turn off soft tabs, it stops converting spaces into tabs, but either way, when I hit enter at the end of a line, autoindent uses a tab instead of spaces.
Cloud9 doesn't have any code that can convert two spaces into a tab.
When soft tabs is enabled it moves cursor as if two spaces is a tab, but that doesn't change characters in the file.
Enter at the end of line copies indentation from that line, and doesn't depend on tab settings.

Notepad++ convert leading spaces to tabs upon entry

Very close to reverse of this question. I prefer coding with 2-whitespace indentation, but need to have files indented with tabs to align with project convention. What I would like to do is preferably automatically convert 2 spaces upon entry to tab symbol in Notepad++ and have the editor configured to tab length of 2.
A possible manual way for doing this could be Edit->Blank Operations->Space to TAB but this converts all of my spaces to tabs, even those of length 1 - which are, for example, spaces between function arguments, not just leading spaces.
In a perfect case scenario I'm trying to achieve formatting style as described in this question, but with typing just spaces and the editor taking care of the rest.
I'm on Notepad++ 6.0, but willing to upgrade if this helps
Let me complete the answer of Ari Okkonen to add a workaround to the problem commented by Sergii Zaskaleta of mixed tabs and spaces at the beginning of the line.
Settings->Preferences->Tab Settings->Tab size: 2 (if not already)
Edit->Blank Operations->Space to TAB (Leading)
Select a block of lines of text with the problem of mixed spaces and tabs. Press [Tab] and [Shift]+[Tab] to add and remove a tab from each line. In the process, the leading spaces had been converted to tabs.
A manual way that seems to work: After having edited the file before saving you may try (Works in Notepad++ v6.8.3):
Settings->Preferences->Tab Settings->Tab size: 2 (if not already)
Edit->Blank Operations->Space to TAB (Leading)

Sublime indentation on per file basis

Using Sublime Text 3. When opening files, some of them have indentation of 2 spaces (while the majority have 4 spaces).
Is there any way to set indentation on per file basis?
In menu select View » Indentation » Tab Width: 2 to set indentation to 2 spaces for the opened file only. Next time you reopen this file Sublime Text guesses the indentation if it is 2 or 4 spaces based on the indentation found in the specific file.
Note: This can technically only work with spaces as indentation. If tabs are used as indentation there is no way to set the tab width on a per file basis, but on a per file type basis.

Customizing Xcode [fonts, code sense, and more]

How can I make code completion case-sensitive?
How can I make Ctrl-k kill the content of the line and the new line character?
How can I make backspace always delete only one character, no matter what it is? Right now, it deletes spaces in chunks equal to my indent level.
How to change the indentation style in file templates? I like to have the opening brace on its own line.
How can I make the font aliased?
I'm using Xcode 3.2.2.
EDIT: Issues 2, 4, and 5 are solved. 1 and 3 are still open.
EDIT2: ad.3. Yes, I set Xcode to use spaces, not tabs.
3.
Look in Preferences : Key Bindings : Text Key Bindings : Indent Friendly Delete Backwards
If the delete key is mapped to this entry change it to plain Delete Backwards.
2.
In that same preference area, you can see that there is no delete line option to map ^k to.
How can I make code completion case-sensitive?
I don't think that's possible.
How can I make Ctrl-k kill the content of the line and the new line character?
I can't answer that one, you might need to write a script to do it.
How can I make backspace always delete only one character, no matter what it is? Right now, it deletes spaces in chunks equal to my indent level.
Backspace always deletes one character. It sounds like your file has tab characters in it, each one of which takes up the space of 4 spaces by default. You can tell Xcode to use spaces instead by de-selecting Tab key inserts tab, not spaces in the Indentation preference panel.
How to change the indentation style in file templates? I like to have the opening brace on its own line.
You need to create custom file templates. You can find the Xcode templates here:
/Developer/Library/Xcode/Templates/File Templates
You need to copy the appropriate templates to this location:
~/Library/Application Support/Developer/Shared/Xcode/File Templates
You can then edit the template files to use whatever indents you like.
How can I make the font aliased?
You need to use a font that has aliased characters. Try Monaco at 9 or 10 points.

Resources