Skip to content

chambln/kakoune-smart-quotes

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
 
 

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/.

plug.kak

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