Package for putting quotes around lines within a paragraph?

I’m a newbie programmer (to say the least) writing the code for a visual novel, and much of the work is just putting quotes around the script the writer sends me. It would save me a lot of time to have a quicker way to put quotes around each line.

Is there a package that would allow me to highlight multiple lines of code and put quotes around each individual one? It currently just puts quotes around the whole highlighted area, and I have to do each line individually. I couldn’t find a package for this, so I figured I would ask.

I don’t know if there is a package for it, but something like this can go in your init script. This file is in ~/.atom (~ being your Home folder). It will probably be called, but if you haven’t added anything to it before it is safe to delete and replace with a file named init.js.

If using init.js, the following example should get you started

// init.js
atom.commands.add('atom-text-editor', {
  "quote-lines": () => {
    const editor = atom.workspace.getActiveTextEditor()
    if (!editor) { return }
    editor.mutateSelectedText(selection => {
      const contents = selection.getText()
      if (contents === "") { return } // if you don't want a cursor to have quotes too

      // customise transformation here
      const lines = contents.split("\n")
      const quoted = => `"${line}"`)
      const result = quoted.join("\n")


Now when you run Quote lines in the command palette, it will wrap each line of each selection in quotes. Note a cursor counts as a selection, hence why we don’t do it if it’s empty.

Right now it will add the quotes to the start of the line, even if it has leading whitespace. It’s up to you to design it how you like; right now I’ve just got it to split each selection’s text into lines, map each line to that line wrapped in quotes, and join it back up and replace the existing text.

You can find the API for the editor variable here, and the API for the selection variable here. Beyond that, most of the string manipulation here is plain JS which any tutorial can cover.

If you want to add a shortcut for this, open up ~/.atom/keymap.cson and add something like the following

# keymap.cson
  "ctrl-t": "quote-lines"

(if the atom-text-editor key already exists, just add the "ctrl-t"... property under this existing one. Also be careful: indentation is significant in CSON files).