Open jnvsor opened 8 years ago
I'd like to reinforce this one, suggesting to add a new configuration: "tabulate_with_spaces" => when set to true the indent/unindent commands will use spaces, pressing tab manually will use spaces, but the tabulations on the clipboard will not be translated.
Currently, the only alternative to the issue is writing a script to turn off the option "translate_tabs_to_spaces", paste the text, and turn it on again, which is a clumsy solution.
Anyone wanting to indent with spaces by default in all files, but having to deal with CSVs and other data files where tabs are significant would benefit from this one.
This also affects duplicating content with mixed tabs and spaces. I actually discovered this while working on a plugin and using view.replace()
. I was moving content from one part of view to another that had mixed indentation, but it was replacing the tabs with spaces due to translate_tabs_to_spaces
, even at this low level. After running view.replace()
I was attempting to move the selection to the new content location, but since the tab character was now four space characters, the length of the selection did not cover all of the content anymore. I thought maybe I was doing something wrong, but seeing as the built-in duplicate command does not work correctly with this either, it seems to be a bug.
The translate_tabs_to_spaces
preference has the comment: Set to true to insert spaces when tab is pressed
, so I would not expect it to change any tabs except when the tab key is pressed. If I want tabs elsewhere to be translated, the Indentation: Convert to Spaces
command could be used.
See the example below using the following content:
<?php
class TestClass
{
public function testFunction()
{
$thisCode = 'thisCode';
$length = strlen($thisCode);
if ($this) {
echo 'then that';
}
}
}
I also just noticed that it does not translate correctly if you do not select the whole line. For some reason it converts the tab to a single space in this example:
Tab indentation mode should only affect indentation, but it's implemented with
translate_tabs_to_spaces
which mangles pastes and prevents any form of tab input at all (Including default keybinds such as "Insert tab"shift+tab
)Steps to reproduce
Environment