Sublime Forum

Sublime text creates unwanted spaces/line breaks. How to switch it off?

#1

When I’m building a website in sublime text for some reason there are spaces/line breaks in places where I started typing on new line. This didn’t happen when I was working with other text editors. Here’s image displaying my problem:

How can I prevent it or switch it off?

0 Likes

#2

What are you doing when you’re typing? You just type test and between each letter, it inserts a \n? When does it happens?

1 Like

#3

I don’t know if it inserts anything (how can I check it?). My sublime text configuration is default, I didn’t change anything.

0 Likes

#4

@Roller I’m quite confused about your problem right now… Could you try re-explaining it in other words. Maybe show us what’s happening by recording your screen and exporting it as a gif (really good, I personaly use it, and it’s free and open source!)

0 Likes

#5

It would also be helpful (to debug) if you open the ST console ctrl+` and paste sublime.log_input(True); sublime.log_commands(True). This will log your keypress and the executed commands in the console.

0 Likes

#6

Just a quick thing about the log: have a look at the Troubleshooting package

0 Likes

#7

This isn’t a Sublime Text issue, it’s just how HTML works.

The line breaks in HTML count as spaces. Browsers will collapse multiple white space characters down to one character, which is why you will always get exactly one space between the text like this T e s t when you write:

T
e
s
t

in your HTML.

So I can assure you, that if you do this in any other editor, you will get the same result.

The solution is to not write things over multiple lines if you don’t want a space between them.

5 Likes

#8

Hmm, I went back to my old text editor to check it and you’re right, it’s behaving the same. The reason the button is falling off is due to wrapper with fixed width. The extra space caused button to not fit in line.

little offtop
Another nice solution is to put a comment between lines. That way there’s no whitespace and you can keep the code clean.

Anyway, thanks for help!

0 Likes

#9

Checkout Bootstrap and UIKit.

Both do somewhat of the same thing, but Boostrap is used more often. They have a grid system so you don’t have to do widths by yourself. Incredibly useful :slight_smile:

0 Likes