Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hotkey to apply "Code" style #1612

Open
cspotcode opened this issue Oct 15, 2024 · 2 comments
Open

Hotkey to apply "Code" style #1612

cspotcode opened this issue Oct 15, 2024 · 2 comments
Labels
feature-request New feature or request styles Related to OneMore My Styles

Comments

@cspotcode
Copy link

Problem to Solve

I often want to quickly paste or type code snippets formatted in monospace, but don't have any hotkey to do this. I have hotkeys for italics, headings 1-6, quotes, and to reset formatting to normal, but no hotkey for "Code."

New Feature/Solution

Keybinding to apply the "Code" style to selected text.

Vanilla OneNote has Ctrl+Alt+1-6 for headings and Ctrl+Shift+N to reset to "Normal." But I've always lamented the lack of a "Code" keybinding.

OneMore adds Ctrl+Alt+Shift+1-9, which is great! But no Code. I'm worried that if I rename the 7th style, Ctrl+Alt+Shift+7, from "Page Title" to "Code," it'll break "Apply styles to this page" and TOC features, because even though OneNote shows me monospace font, it secretly thinks the text is a "Page Title."

If OneMore added a "Code" keybind, then I could:

  1. Write or paste some code.
  2. Ctrl+Shift+Up to highlight it.
  3. Press new "Code" keybind -- Ctrl+Alt+C? -- to format as monospace.
  4. Press F6 or Alt-F6 to wrap in a (code) box.

Alternative Solutions

#1314 could work, but the "Code" header eats up screen real-estate so I'm hoping to use the Alt+F6 "Text Box" instead.

I'm not sure that #1314 can be cleanly implemented, because it would destroy the formatting of selected text. This might be nice sometimes but not all the time, so it would need a way to opt-in or opt-out and that's more complex.

@stevencohn
Copy link
Owner

Ctrl+Alt+Shift+1-9 map to the first 9 custom styles. You have the ability to reorder your custom styles. As long as you keep "code" within that range, you're good to go.

Having another special key binding would present exactly the same naming problem that you mention. In other words, you still have to be careful to maintain the name. And remember that OneMore is translated to multiple languages so that key binding would need to be dynamic and set by the Settings dialog, adding quite a bit of complexity far above and beyond just using Ctrl+Alt+Shift+1-9.

Note also the OneMore Quick Style palette which you open using Ctrl+<comma> and then type "code" to apply your custom code style (or whatever you name your custom monospace style)

@cspotcode
Copy link
Author

OneMore Quick Style palette

I didn't know about this, thank you! This solves my problem.

Having another special key binding would present exactly the same naming problem that you mention.

Ok, I had imagined it would be akin to OneNote's native Ctrl+Shift+N, which always applies OneNote's native "Normal" style. I was thinking that, if native OneNote has a hotkey dedicated to "Normal" style, then OneMore could add one fully dedicated to OneNote's "Code" style. (doesn't even need to be a OneMore style) But I think I understand what you're saying: styles must always be looked up by index, cuz OneNote doesn't expose an API akin to GetWellKnownStyle(Styles.NORMAL) or anything like that.

You have the ability to reorder your custom styles

Thanks, to be honest, I hadn't found the button for reodering. :( My mistake.

I had been worried that reordering would mess up ToCs, and didn't fully understand the warning shown here:
image

But seems like moving "Code" into position 7 doesn't affect ToCs! And "Quick Style palette" also solves my problem, so it's a non-issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request styles Related to OneMore My Styles
Projects
None yet
Development

No branches or pull requests

2 participants