Is there a way to bind a set of keys to “Toggle Soft Wrap” ?
I wanted to do precisely this, but am falling at the first hurdle. I tried adding these lines to my
'.editor': 'alt-cmd-\': 'editor:softWrap'
but this seems to have no effect (after restarting app, too). What is the correct way of adding this toggle to the keybinding? (I’m surprised it isn’t already assigned “out of the box”, actually!)
There are a few issues with your example:
- The command is
- The syntax you have for the keystroke is incorrect, it should be
'alt-cmd-\\'. The single backslash escapes the single quote so the string doesn’t end until just before the
- Cmd+Alt+\ conflicted with one of the default keyboard shortcuts in my installation of 1Password.
Even when I disabled that shortcut, Cmd+Alt+\ was not recognized properly … but when I changed the keymap to use Cmd+Alt+Shift+Z (a key combination that I use specifically for testing key mappings because I know I’m not going to use it for anything else), everything worked fine. I’ve filed a bug about the Cmd+Alt+\ thing … because the behavior just seems weird when I look at it using the Keybinding Resolver.
Turn on Line Wrap
Thanks so much for spelling that out. Maybe I should have guessed about double-backslash; OTOH, it would be welcome to have that noted in the documentation (and if it’s there, I missed it: I did read it! really!)
cmd-alt-\\ works well for me (Ubuntu 14.04, fwiw). It’s the same combination as the TextAdept toggle, and I prefer not to proliferate these if I don’t have to.
Where would one look to know that
toggle-soft-wrap is the correct form for this feature? I didn’t spot that either. (So not doing very well, then! =/)
Meanwhile, it’s good to have this example working. Thanks again!
Actually, what caught that for me was the CSON syntax highlighting
I used Cmd+Shift+P to bring up the Command Palette and then typed
soft to search for soft wrap, found the command:
Then I just reversed the standard string conversion:
Editor: Toggle Soft Wrap →
Awesome, thank you for posting this!
Took me way too long trying to figure out the necessary keymap command for a quick toggle for soft wrap. Is this helpful nugget officially documented somewhere? I looked to no avail…
I tried guessing (unsuccessfully) based on the corresponding API method, but your instructions were dead on!
The new documentation has an in-depth section on key bindings: https://atom.io/docs/latest/behind-atom-keymaps-in-depth.
In particular, the last paragraph of the Commands section states:
I want the soft wrap to be on, by default. Is that possible?
- Launch Atom
- Open the Settings View using Cmd+, on OS X or Ctrl+, on other platforms
- Scroll down to the box marked “Soft Wrap”
- Put a check in it
Ah, there it is:) Your the man leedohm, thank you.