geddski / macros

macros support for VS Code
MIT License
165 stars 36 forks source link

I cannot get replace command to work #62

Closed mark-hahn closed 2 years ago

mark-hahn commented 2 years ago

I'm trying to make a keybinding that converts double-spacing to single in the active file. In other words I want to replace \n\n with \n across the file. I set this up but I can't get it to work.

My settings entry ...

  "macros": {
    "removeDoubleSpacing": [
      {"command": "replace", 
       "args": {
          "regex":          true,
          "replaceAll":     true,
          "global":         true,
          "multiline":      true,
          "searchPattern": "\n\n",
          "replacePattern": "\n"
        }
      }
    ]
  },

my kebindings.json entry ...

  {
    "key": "ctrl+9",
    "command": "macros.removeDoubleSpacing"
  },

What am I doing wrong? Is there a way to do this in vscode without an extension? Thanks in advance.

mark-hahn commented 2 years ago

I switched to Replace Rules and there was an example for just what I needed. So I"m good to go. However, it would still be nice to know what's wrong for future use, and for googlers to find.