Textmate 2 indentation with Python - textmate

When I indent by tabbing "Tab" key, the tab is replaced by 4 spaces. Does anyone know how could I set it to normal?

At the bottom of the editor window there is a menu for tab size, you can set the desired width there as well as turning on soft tabs which inserts spaces instead of tabs but treats them as tabs when editing. Your choice will be saved based on the active file type so make sure to set it when in a python file.

Related

Sublime behavior like in VS

How to do same behaving in Sublime Text as in Visual Studio, when using column selection
for example if there is a line break in a text, the cursor in Sublime go to beginning of a line
And this is behavior in Visual Studio desired behavior
Thanks
While you may want this functionality for other reasons, it seems like you are using it to adjust the indentation of code blocks. Fortunately, there is a much easier way of doing this. Select the text for which you want to change the indentation, then press Ctrl] to increase the indentation (move block right), or Ctrl[ to decrease indentation (move block left). You can also increase indentation by selecting the desired lines and hitting Tab, and using ShiftTab to decrease it. The one place I can think of where multiple selections would come in handy is if, for some reason, you need to indent/dedent by fewer spaces than are in your tab stop. For example, if I have some code that's indented 3 spaces, and I want to change it to 4 (using the Indent Using Spaces setting in the View -> Indentation menu), I would use a multiple selection to put a cursor on each line, then use Space or Backspace to adjust spacing appropriately.

Changing all my indents to 3 spaces. Code::Blocks

I have to submit an assignment and they want all the indents to be 3 spaces. I don't know how to change the settings of Astyle.dll so that it will change them 3 spaces instead of the default 4. Any ideas?
Also, Astyle seems to like having no indent between switch() and its cases, and I need there to be an indent there. Any ideas?
All of Astyle's settings are exposed in the Code::Blocks editor settings dialog. To access them, open the Settings menu, click Editor, and scroll through the sidebar to find the Default code entry.
I have to submit an assignment and they want all the indents to be 3 spaces.
Switch to the Indentation tab, found under Source Formatter in the sidebar, and change Indentation size (in spaces): to 3.
Also, Astyle seems to like to have no indent between switch() and its cases, and i need there to be an indent there.
If I understand what you need correctly, check the box that says Indent switches (keyword case:) and check the box that says Indent case: statement in switches (commands under case:).
You can change any other settings you want as well. When you're done, hit OK, then reformat your code and make sure the settings are set the way you want them.

How to set TextMate Soft Tabs to 1?

I want my tabs to be 1 space only, however, TextMate does not let me do it. Is there a way of doing it?
thanks
Click the tab size popup in the status bar, enable soft tabs, select "other..." and set it to 1.
Source- the textmate website:
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.
set a .tm_properties file in either ~/ or your project root to with the following content:
softTabs = true
tabSize = 1
Your preference is, like comments imply, rather strange, but serviceable nonetheless.

Can TextMate show tab vs space characters?

Using TextMate on Mac, the "invisibles" can be displayed by using
View -> Show Invisibles
But the space vs tab characters are not shown, and Preferences doesn't seem to have any entry to change that either. Is there a way to show them? It is because some older coder may have tab or space mixed together so what looks good in the editor may actually be misaligned. (editor shows tab as 2 spaces)
Tab characters are shown, but spaces are not. What's probably happening is that you have Soft tabs turned on, in which case the tabs are converted into spaces automatically.
alt text http://grab.by/grabs/fabaea391dc8bc764636f0ca19a8c38d.png
In this picture there is a tab character, new line, tab character, new line, soft tab, new line
See this thread for an explanation as to why spaces are not shown.
Here is where you can change soft/real tabs.
alt text http://grab.by/grabs/783db3a88609a01c7702cbd250f495c6.png
If "Show invisibles" is activated, you will see a little triangle for each tab, which points to the right. Spaces are not shown at all, you can only see them indirectly, i.e. via the symbol which represents the line break. If the line break isn't the first character after your code of that line, there are spaces in between.
So to make a long answer short: You should already see tabs, however the symbols representing the invisibles are sometimes hard to see.

How to indent a selection in gVim (Win32)

I'd like to indent a block of text.
I am able to do this in the Linux build of gVim.
I do this in the state of gVim where I'm not in the insert or visual mode. The bar at the bottom is blank on the left, and the line number and percentage are showing on the right hand side.
Then I perform the following procedure: I select a block of text via click and drag. Then I hit Shift + .. After that, I hit Esc and the block of text will move over a tab.
If I do this in Windows however, it just replaces the block with >.
I am just running the stock Windows rc file and version 7.1 of gVim.
If you first enter SHIFT-V, and than shift+arrows to select the text, it will indent.
You can also use SHIFT-V, and use 'hjkl' to select the block.
If you use shift+arrows or the mouse to select a block of text, it does not work and the selection will be replaced with a '>'. This can be changed when you change selectmode;
set selectmode=mouse,key
default setting after behave mswin
set selectmode=key
now you can select with the mouse and press '>' to indent
set selectmode=
now you can select both with the mouse and shifted arrow keys and press '>' to indent
If you add this to your vimrc, do it after behave mswin
Related to this, I use a handy remap for visual mode that allows indenting the text multiple times while keeping your text selected. Similar to how visual studio lets you select and hit tab (or shift-tab) to indent.
Add the following to your .vimrc
" Pressing < or > will let you indent/unident selected lines
vnoremap < <gv
vnoremap > >gv
Also you can use == to have vim try and determine the correct indenting automatically. It will work on any line buy just placing the cursor there and pressing == or you can do fancy stuff like select the entire file and press == to fix all the indenting (works wonders on html generated by wysiwyg editors).
Esc -> Shift+V -> Select Lines -> > >
You need to change behave mswin to behave xterm in your vimrc file.
You can use text objects if you want to avoid visual mode entirely. For example >ap in Normal mode indents one paragraph, >aB indents one curly-brace block, etc. See :h text-objects.

Resources