Sublime Forum

View.insert changes indentation of inserted text

#1

The View.insert et al. commands changes indentation of inserted text, for example when "translate_tabs_to_spaces" is set to true. This makes it impossible to create plugins that insert very specific characters, like version control plugins or search and replace plugins.

Possible solutions: either the commands should not manipulate the text, or there should be a more basic edit command that inserts text verbatim.

See https://github.com/gornostal/Modific/issues/101

Is there a way to insert text so that it is not changed by Sublime Text itself?

I’m using Sublime Text Build 3102 on OS X 10.11.3.

0 Likes

How to insert text on view with no indentation?
#2

Can reproduce on ST3 Build 3102 running on Ubuntu 15.10.

0 Likes

#3

edit_view is a command implemented by the Modific package, so this report is kind of misleading. The actual issue is as follows:


If "translate_tabs_to_spaces": true is set, every literal tab character (\t) gets replaced on text insertion - on the lowest API level, which is View.insert or View.replace. It also happens with the insert and append commands.

The same applies to the auto_indent setting, by the way, which also annoyingly auto-indents all code as if it was inserted literally, even if you pre-formatted it already. You can see the effects of that here:


The current workaround involves unsetting these setting before inserting your pre-formatted text, as I did here:

1 Like

Merging Buffers to Merge Different Windows
#4

Thanks, I’ve updated the original post to reflect the Sublime Text commands instead.

0 Likes