2

My work wants us to use left and right double quotes while typing documentation. I want to use the LaTeX style ones because I write papers in LaTeX often and I already type them automatically.

I am new to clojure but did manage to find this:

(def mystring "``quoted string''")
(clojure.string/replace mystring #"``|''" {"``" "“" "''" "”"})

This will output:

“quoted string”

So I want to tie this functionality to a command using keybindings. I was going to ask how to tie the above command. But then I read this bit on how standard clojure libraries don't integrate so well with LightTable: How to integrate libraries (clojars) into Lightable plugins

I keep reading about regexs. Is there a way to apply a regex across an entire file?

What I'm thinking is I will type up the document and then at some point, hit (ctrl-i) or whatever and have it automatically replace the LaTeX characters with my work's desired characters.

If it was possible to have something auto-replace them while I type, that would be amazing. But I'm new to this so going with baby steps.

Community
  • 1
  • 1
Darrell
  • 46
  • 5
  • 1
    What version of light table are you using? If it is later than .5 or .7 i can definitely help you out with this. – Adam Jul 23 '15 at 14:38
  • I am using 0.7.2 at the moment. An alternative for this would be with auto-close enabled and functional for double-left-quote and double-right-quote. But I would still need to map a specific key to the double-left-quote. I'm not really ok with holding down alt and typing four numbers. :) – Darrell Aug 06 '15 at 17:23
  • For now, I have settled on this keybinding as a workaround: [:editor "`" (:editor.open-pair "“”")] This binds backtick to doing a double-left and double-right pair. I tried using open-pair and close-pair but close-pair never worked. – Darrell Aug 06 '15 at 18:18
  • If you have any further questions, just let me know what version of lighttable you are using. Else you should answer your own question and accept it. – Adam Aug 06 '15 at 19:50

1 Answers1

0

The solution I ended up using is the following key binding:

[:editor "ctrl-shift-q" (:editor.open-pair "“”")]

When I press my key combo, in this case control-shift-q, it drops the left-double-quote and right-double-quote into the document with my cursor in the middle.

I would still prefer to have something that replaced any double backtick "``" with a left-double-quote and any double apostrophe "''" with a right-double-quote but This works great for now.

Darrell
  • 46
  • 5