Sublime Forum

Indenting Issue

#1

Hi

I’m new to sublime - trying to get it configured so it indents as per my previous editor. The current issue I have is when I do a foreach loop, for example:

If I type the first line shorthand php and press enter, it’ll indent an extra level - I’d like it to stay on the same level.

<?php foreach( $users as $user ): ?>

	<?php endforeach; ?>

Another example:

<?php foreach( $users as $user )
{
    // Auto indents to this level
}

Essentially what I’m after is whenever enter is pressed - it’ll go to a new line at the same level as the previous line.

If someone can point out how I can turn off code completion too that would be useful.

Thanks

0 Likes

#2

The global auto_indent / smart_indent options won’t give you the behaviour you want.

If you want fine-grained control you’ll need to adjust the default autoindent rules per-language. Can’t remember the details, but in broad-brush the defaults in question are usually in an XML file named something like 'Indentation Rules.tmPreferences' which is stored - in Sublime Text 3 - inside the sublime-package file for each language package (these are ZIP files with a different extension).

To the question of overriding them, I can’t remember the ‘right’ approach for this, so perhaps someone could chime in here. I’d probably start by creating a language overrides .tmPreferences file in Packages\User, copy the relevant XML from the original package file, then empty out the XML keys decreaseIndentPattern, indentNextLinePattern and bracketIndentNextLinePattern.

To your other question, completion suggestions can be turned off by adding:

"auto_complete": false

to your user preferences.

:slightly_smiling:

0 Likes