Sublime Forum

Typewriter: a plugin for writers

#1

The Typewriter plugin provides two typewriter-inspired modes for Sublime Text 2 & 3:

  • Typewriter Scrolling keeps the view centred on the current line, when there is more than half a screenful of text, à la iA Writer, WriteRoom and the like.
  • Typewriter Typing disables your cursor keys and all bindings that move the cursor and/or select text, leaving you only with letters, numbers, symbols, Backspace, Delete and Enter. (Windows & Linux only.)

Get it: github.com/alehandrof/Typewriter

Credits:

  • Scrolling mode was written by castles_made_of_sand & facelessuser way back when: Always centered cursor
  • Typing mode is an embarrassing hack I threw together for my own use. I would not have published it, had I not found it to be tremendously useful for drafting.

Cheers,
Alex

0 Likes

Package always needs to be toggled on
#2

Real typewriters don’t let you delete text…! :smile:

0 Likes

#3

Sounds like a feature unrequest :smile:

0 Likes

#4

Exactly :smile:

I wish there were some way in unicode (or Sublime Text) to combine arbitrary characters - it would be awesome if backspace could just let you type over your previous characters.

0 Likes

#5

Without testing, and just by reading, I think you need to tweak the function to guess the focused view; because in cloned views, the view argument of the on_modified is not the same view on which you are writting. IIRC.

github.com/SublimeText/BufferSc … #L142-L149

0 Likes

#6

@icylace I think you mean an unfeature request :smiley:

@adzenith That was my first thought as well. But that would be trying to make a digital typewriter.

I think I’ve found a happy compromise in trying to figure out how to encourage user behaviour* that’s similar to that caused by an actual typewriter, while maintaining the benefits of the digital format. I use git for version control; what would be the use of ████████ █████ ██████████ a bunch of CIA-style redactions in my repo’s history? Does this line of thinking make sense?

(* I’m referring to myself. YMMV.)

@tito Thanks for pointing this out. I’ll have to look into your code (and possibly steal some of it). I use Typewriter Scrolling almost exclusively in Sublime’s Distraction Free mode, so it hadn’t come up as an issue. (FWIW, I do point to BufferScroll as a more featureful alternative :smile:)

0 Likes

#7

Anyone with OSX care to test something for me? It will only take a couple of minutes.

0 Likes

#8

Sure, what’s up?

0 Likes

#9

Hey @adzenith, thanks for offering.

Can you try these bindings out (one at a time) and let me know if either or both disable your left cursor key in OSX?:

// { "keys": "left"], "command": "do_nothing" },
// { "keys": "left"], "command": "unbound" },

For Windows & Linux the navigation keys are bound explicitly in the Default keymap, but not so in the case of OSX. So, I’m wondering…

Alex

0 Likes

#10

Both disable my left arrow key… and then I have to delete them with my mouse because I can’t use my left arrow key :stuck_out_tongue:

0 Likes

#11

Thank you very much for testing this out. It works as intended.

(And sorry for crippling your editor. It’s a right panic when your cursor keys are misbehaving. Video games used to swap the keys around to simulate drunkenness or weakness.)

I’ll be uploading a rough draft of the Typing Mode for OSX later today. I’m doing this a bit blindly, because I haven’t been able to really thorough list of text editing shortcuts for OSX. I will need another volunteer (or the same) to test that out when it’s ready. And this time there will be an off switch :smile:

Alex

0 Likes

#12

I’ve updated the Typing mode to support OSX. It’s 100% untested guesswork at this point.

I would be very grateful if a gentle soul could install Typewriter from the repo [1], turn on Typing mode (via the Palette) and try to move the cursor.

[1]: git clone [github.com/alehandrof/Typewriter.git](https://github.com/alehandrof/Typewriter.git)

In theory, typing mode should only allow you to type alphanumeric characters, punctuation & symbols, enter and backspace/delete. In practice, let me know what happens.

P.S. The Typing mode command is a toggle so you can return your editor to its former state, although it only takes effect per-view.

Alex

0 Likes

#13

Incidentally, I added this to Package Control as of a couple of weeks ago: https://sublime.wbond.net/packages/Typewriter

I’m still waiting for some nice OSX folk to verify whether the Typing mode works as it should:

Cheers,
Alex

0 Likes

#14

Just tried it on OS X. I can still press up and down, but that’s probably because I have them rebound in my user keybindings.
I can’t “undo”, but I can “find” - again, probably because I rebound find.
I can still move the cursor with the mouse.

0 Likes

#15

Thanks for the report.

If you’ve rebound keys, then the keymap settings I provide won’t know, obviously. What I would really like to do is to temporarily disable commands (such as “move”, “find_prev”, etc.). I couldn’t think of a way of doing that, so I’m just stepping on the default keybindings. I’m still thinking about a Pythonesque solution.

Whether all this is an issue or not for actual writing depends on whether you can resist the urge to use loopholes to go back and edit the text you’ve written. (Erasing and re-writting is acceptable :smile: ) The version of this plugin I used for a long time only blocked the cursor keys, which was sufficiently demoralizing for me, but YMMV.

Just out of curiosity, what have you bound up and down to?

Alex

0 Likes

#16

In ST3, you can probably use this event:

on_text_command(view, command_name, args) (new_command_name, new_args) Called when a text command is issued. The listener may return a (command, arguments) tuple to rewrite the command, or None to run the command unmodified.
Returning a nonexistent command (like ‘blackhole’ :wink:) will probably cancel the current command and do nothing (didn’t try), otherwise you can write your own BlackHoleCommand to trigger instead.

0 Likes

#17

[quote=“bizoo”]
In ST3, you can probably use this event:

on_text_command(view, command_name, args)	(new_command_name, new_args)

Buwahahaha! This is so brutally effective it’s not even funny.

It looks like it also allows me to block mouse events, which I’ve been wanting to do for the typewriter scrolling mode since 2011.

Thank you @bizoo for pointing this out. I am totally grinning like an idiot right now.

Alex

Edit:

Indeed, I’ve been using do_nothing.

0 Likes

#18

github.com/bizoo/SmartCursor

0 Likes

#19

I’d tried one of the first versions of SmartCursor, but I never got the hang of it. IIRC, I had bound it to something I needed to trigger consciously, and of course I never did. But it still sounds intriguing enough to try it again.

I used to be wary of modifying the editor so fundamentally, because the muscle memory would not transfer to other environments. But I’ve pretty much given up writing text in anything other Sublime. (As the Typewriter plugin indicates.)

Who knew? The Emacs people were on to something…

(It just occured to me that I still have to use Excel on occasion. Boy, does that app need multiple cursors! :smiley: )

Alex

0 Likes

#20

You’re right, it’s too difficult to use it this way, I couldn’t either.

I’ve bound them to up/down keys one year ago and use them this way since.

It’s a hit-and-miss feature, sometimes it does exactly what you want, sometimes it doesn’t. But I think that the hit ratio is bigger than the miss ratio.
I don’t consciously use this feature, it’s just that often you hit the down key and you find that the caret is magically where you want it to be.

0 Likes