Iāve been using the excellent distraction free mode in Sublime and I love it. I also created some user prefs for Markdown mode that attempts to mimic Writer on the iPad. I can get pretty close. Itās really nice. BUT, I canāt get the current line to stay centered on the screen like writer does. Is this something that is possible via the API or some hidden setting. Also, the way lines fade out above and below the current line in Writer is nice. Again, possible in Sublime somehow? I thought a species syntax might do itā¦?
Sublime Writer
Iām not familiar with Writer, but this may approximate what youāre after regarding the cursor.
Bind this to āenterā in your user keybindings.
Note that it only keeps the cursor centered in the screen; you have to place it there first.
[code]import sublime_plugin
class SublimeWriter(sublime_plugin.TextCommand):
def run(self, edit):
self.view.insert(edit, self.view.sel()[0].begin(), ā\nā)
self.view.run_command(āscroll_linesā, {āamountā: -1.0})[/code]
And this will give you the middle point:
v = view.visible_region()
a = view.rowcol(v.begin())[0]
b = view.rowcol(v.end())[0]
middle = (b + a)/2
HTH,
G
In v1 it used to be possible to issue a sequence of commands in a single key binding. That would eliminate the need for the plugin, but I havenāt figured out yet how to do this in v2ā¦
When I implement distraction free mode in Sublime Text 2, Iāll see what I can do to get some of these incorporated.
Hi all,
I, too, am hoping to get Sublime Text 2 to behave more like WriterRoom or iAās Writer.
I failed to use the code snippets provided by guillermooo. (I use ST for CSS, HTML and regular text; I havenāt programmed in a decade.) Iād be grateful for any help implementing them.
Since STās API has a show_at_center(point) function, it seems fairly straightforward (for someone who can write Python) to implement the centering effect. The code would be the python equivalent of: after each keypress, show_at_center(where there cursor is). This might break STās more advanced features, but if all youāre doing is writing text, I think it should work okay.
The fade out effect is more complicated, because iAās Writer doesnāt just highlight the line, it highlights the sentence. (See http://www.geekosity.org/wp-content/uploads/2011/06/iA-Writer.png) Implementing this would break compatibility with TextMateās themes, which presumably is undesirable.
A rather complicated plugin might be able to grab the text between the two punctuation points (. ? ! for English) before and after the cursorās position and call that regular text, while making everything else styled as a comment (which tend to be themed so that they fade into the background). Of course, this would stumble on a text like āDid you know? St. Jerome was a saint.ā (It would think that āSt.ā was a complete sentence.)
I hope that the above is not too muddled. I also was not sure whether I should reply here or post a new topic under the Ideas & Feature Requests section. (Iām not activate on forums that much, except when I love the app!)