← Back to Documentation

Editor Setup for Cure String Literals

This guide helps you configure your editor to easily input Unicode curly quotes (' and ') for Cure charlist literals.

Implementation Status: Charlist literals with Unicode curly quotes are fully implemented in the Cure lexer and tested (see test/string_lexer_test.erl). However, in practice, most Cure code uses regular strings ("hello") for text. Charlists are primarily for Erlang interoperability when needed.

Quick Reference

Cure uses different quote characters for different purposes:

Character Unicode Usage Example
" U+0022 String literals "hello"
' U+2018 Charlist start 'hello'
' U+2019 Charlist end 'hello'
: U+003A Atoms (recommended) :my_atom
' U+0027 Atoms (alternative) 'my_atom'

Operating System Methods

macOS

System-wide Keyboard Shortcuts:
- Left curly quote ': Option + ]
- Right curly quote ': Option + Shift + ]

Text Substitution (Automatic):
1. Open System Preferences → Keyboard → Text
2. Add entries:
- Replace: '' → With: '' (two single curly quotes)
- Or configure your preferred trigger

Linux

Compose Key Method:
1. Set a compose key in your keyboard settings
2. Use sequences:
- ' (left): Compose < '
- ' (right): Compose > '

XKB Custom Layout:
Create a custom keyboard layout in ~/.config/xkb/symbols/custom:

partial alphanumeric_keys
xkb_symbols "cure_quotes" {
    include "us(basic)"
    key <AC10> { [ apostrophe, quotedbl, U2018, U2019 ] };
};

Apply with: setxkbmap -option "custom:cure_quotes"

Windows

AutoHotkey Script:

Save as cure_quotes.ahk:

; Cure Charlist Quotes
; Press Alt+[ for left curly quote
; Press Alt+] for right curly quote

![ ::SendInput {U+2018}  ; Alt+[
!] ::SendInput {U+2019}  ; Alt+]

Run the script on startup.

Editor-Specific Configurations

VS Code

Method 1: Custom Keybindings

Add to keybindings.json:

[
  {
    "key": "alt+[",
    "command": "type",
    "args": { "text": "'" },
    "when": "editorTextFocus && editorLangId == 'cure'"
  },
  {
    "key": "alt+]",
    "command": "type",
    "args": { "text": "'" },
    "when": "editorTextFocus && editorLangId == 'cure'"
  }
]

Method 2: Snippets

Add to Cure language snippets:

{
  "Charlist Literal": {
    "prefix": "cl",
    "body": "'$1'",
    "description": "Insert charlist literal with curly quotes"
  }
}

Method 3: Text Expander Extension

Install an extension like "Text Expander" and configure:
- 'c' (left curly quote)
- c'' (right curly quote)

Vim/Neovim

Method 1: Insert Mode Mappings

Add to .vimrc or init.vim:

" Cure charlist quotes
inoremap <A-[> '
inoremap <A-]> '

" Or use digraphs (Ctrl+K followed by code)
" '<' for U+2018, '>' for U+2019

Method 2: Abbreviations

" Auto-expand ''c to charlist quotes
autocmd FileType cure inoreabbrev ''c ''

Method 3: Custom Digraphs

digraphs c< 8216  " '<
digraphs c> 8217  " '>

Then use: Ctrl+K c < for '

Emacs

Method 1: Custom Keybindings

Add to .emacs or init.el:

;; Cure charlist quotes
(define-key cure-mode-map (kbd "M-[") 
  (lambda () (interactive) (insert "'")))
(define-key cure-mode-map (kbd "M-]") 
  (lambda () (interactive) (insert "'")))

Method 2: Abbrev Mode

(define-abbrev cure-mode-abbrev-table "'c" "''")

Method 3: YASnippet

Create cure-mode/charlist.yasnippet:

# -*- mode: snippet -*-
# name: charlist
# key: cl
# --
'$1'$0

Sublime Text

Method 1: Key Bindings

Add to Preferences → Key Bindings:

[
  {
    "keys": ["alt+["],
    "command": "insert_snippet",
    "args": {"contents": "'"}
  },
  {
    "keys": ["alt+]"],
    "command": "insert_snippet",
    "args": {"contents": "'"}
  }
]

Method 2: Snippets

Create cure-charlist.sublime-snippet:

<snippet>
    <content><![CDATA['$1']]></content>
    <tabTrigger>cl</tabTrigger>
    <scope>source.cure</scope>
    <description>Charlist Literal</description>
</snippet>

IntelliJ IDEA / WebStorm

Live Templates:

  1. Go to Settings → Editor → Live Templates
  2. Create new template group "Cure"
  3. Add template:
    - Abbreviation: cl
    - Template text: '$END$'
    - Applicable in: Cure files

Keymap:

  1. Settings → Keymap
  2. Search for "Insert Live Template"
  3. Add shortcut: Alt+[ for ', Alt+] for '

Atom

Snippets:

Add to snippets.cson:

'.source.cure':
  'Charlist Literal':
    'prefix': 'cl'
    'body': "'$1'"

Keybindings:

Add to keymap.cson:

'atom-text-editor[data-grammar="source cure"]':
  'alt-[': 'snippets:insert-text-left-curly-quote'
  'alt-]': 'snippets:insert-text-right-curly-quote'

Language Server / LSP Support

If you're using a Cure language server, it can provide:

Auto-Closing Pairs:
- Typing ' automatically inserts '
- Cursor positioned between quotes

Snippet Completion:
- Type char or cl → charlist literal template

Diagnostics:
- Warns when using ASCII ' for charlists
- Suggests correction to Unicode quotes

Copy-Paste Method

If configuring your editor is too complex, you can:

  1. Create a file snippets.txt with commonly-used patterns:
    '' (empty charlist) 'hello' 'world'

  2. Copy-paste as needed

  3. Or use a clipboard manager with pre-configured snippets

Testing Your Setup

Create a test file test.cure:

module Test do
  export [main/0]

  import Std.Io [println/1]

  def main(): Int =
    # String literal (straight quotes)
    let str = "hello"
    println(str)

    # Charlist literal (curly quotes) - stores as [104, 101, 108, 108, 111]
    # let chars = 'hello'

    # Atom (ASCII single quote)
    let atom = :my_atom

    0
end

Verify:
- "hello" → String (UTF-8 binary)
- 'hello' → Charlist (list of Unicode codepoints: [104, 101, 108, 108, 111])
- :my_atom → Atom (recommended syntax)
- 'my_atom' → Atom (alternative ASCII single quote syntax)

Troubleshooting

Characters Not Displaying

Issue: Curly quotes show as boxes or question marks

Solution: Ensure your editor uses a Unicode-aware font:
- Recommended fonts: Fira Code, JetBrains Mono, Source Code Pro
- Enable UTF-8 encoding in editor settings

Incorrect Character Inserted

Issue: Wrong Unicode character inserted

Solution:
- Verify the Unicode codepoints: U+2018 (left) and U+2019 (right)
- Check your keyboard layout or input method
- Use xxd or a Unicode inspector to verify characters

Auto-Pairing Conflicts

Issue: Editor's auto-pairing interferes with charlist quotes

Solution:
- Disable auto-pairing for single quotes in Cure files
- Configure language-specific settings
- Use explicit keybindings instead of relying on editor defaults

If Unicode input is impossible in your environment, you can use ASCII single quotes for atoms instead:

# ASCII single quote for atoms (fully supported)
atom = 'my_atom'

# Or use colon prefix (recommended)
atom = :my_atom

Note: Charlists with Unicode curly quotes are implemented and tested in the compiler (see test/string_lexer_test.erl), but are rarely used in practice. Most Cure code uses strings ("hello") for text and atoms (:atom) for symbolic values.

Contributing

Found a better method for your editor? Please contribute:

  1. Fork the Cure repository
  2. Update this document with your configuration
  3. Submit a pull request

See CONTRIBUTING.md for guidelines.

Resources

Support

Need help configuring your editor?

Happy coding! 🎉