Skip to content

Kakoune plugin that converts 'straight' "quotes" to ‘curly’ “quotes” as you type.

License

Notifications You must be signed in to change notification settings

chambln/kakoune-smart-quotes

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 

Repository files navigation

Smart quotes for Kakoune

This simple Kakoune plugin converts typewriter-style straight quotes to typographically pleasing curly quotes as you type.

'example'  →  ‘example’
"example"  →  “example”
I'm        →  I’m

Demonstration of smart quoting in Kakoune

Installation

Manual

Put a copy of or link to smart-quotes.kak anywhere within ~/.config/kak/autoload/.

Suggested configuration:

plug chambln/kakoune-smart-quotes config %{
    map global insert <a-'> "<a-;>: smart-quotes-insert \' ‘ ’<ret>"
    map global insert <a-"> '<a-;>: smart-quotes-insert \" “ ”<ret>'
    hook global \
         WinSetOption \
         filetype=(mail|markdown|restructuredtext|git-commit) \
         smart-quotes-enable
}

Usage

Manually enable smart quoting in the current window:

:smart-quotes-enable<ret>

Enable smart quoting for one insert session:

:smart-quotes-mode<ret>i

Always use smart quoting for e.g. reStructuredText:

# ~/.config/kak/kakrc
hook global WinSetOption filetype=restructuredtext smart-quotes-enable

Use Alt to smartly insert a quote:

# ~/.config/kak/kakrc
map global insert <a-'> "<a-;>: smart-quotes-insert \' ‘ ’<ret>"
map global insert <a-"> '<a-;>: smart-quotes-insert \" “ ”<ret>'

Or use guillemets instead:

# ~/.config/kak/kakrc
map global insert <a-'> "<a-;>: smart-quotes-insert \' ‹ › <ret>"
map global insert <a-"> '<a-;>: smart-quotes-insert \" « » <ret>'

Notes

  • Repeated keypresses cycle opening, straight, and closing quotes.
  • <c-v> bypasses smart-quotes whereas \i does not.
  • A contraction at the beginning of a word should have an apostrophe (), but smart-quotes will erroneously insert an opening quote () instead; e.g.
    • the ‘80s (incorrect) instead of the ’80s (correct),
    • fish ‘n’ chips (incorrect) instead of fish ’n’ chips (correct).

About

Kakoune plugin that converts 'straight' "quotes" to ‘curly’ “quotes” as you type.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published