Sublime Forum

Insert new line after specific character

#1

I am looking for a way of automatically inserting a line break after every period + space sequence. I can have TextExpander do that replacement whenever I’m working with ST3, but I’m wondering if I can do this with Sublime alone.

If so, is there a way of restricting this functionality to a particular syntax? I’m particularly interested in using this for text-heavy files for the purposes of version control.

Is there any way of implementing something like this with Sublime?

0 Likes

#2

Find > Replace…
find: .
replace:

[code].

[/code]
To put a newline in the replace box, you’ll have to hit ctrl+enter (win/lin) or option+return (mac).

0 Likes

#3

Thanks. I’m actually looking for a way to do this as I type. Or at any rate, to automate this process.

0 Likes

#4

OK, I think this seems to work.

{ "keys": " "],
		"context":  
				{"key": "selector", "operator": "equal", "operand": "text.tex.latex"},
				{"key": "preceding_text", "operator": "regex_match", "operand": "^.*\\.$"}
				],
		"command": "insert", "args": {"characters": " %\n"}
	}

I may be about to break something, for all I know. But so far, it does the trick.

1 Like