1

I have a console log snippet for Sublime Text 3.

{
    "keys": ["alt+super+l"],
    "command": "insert_snippet", 
    "args": {
        "contents": "console.log('$1', $2)"
    },
    "context": [
        { "key": "selection_empty", "operator": "equal", "operand": true, "match_all": true },
    ]
}

I would like for there to be multiple cursors, so that, when I call the key for this snippet, the cursor is at both the $1 and the $2 locations, as I often just want to log the variable name and the variable value in the console. How do I manage this?

4

1 回答 1

4

在两个地方都使用${1:placeholder}(或只是$1)。对于您的特定片段,它看起来像:

{ ...
        "contents": "console.log('${1:variable}', ${1:variable})"
    ...
}

如果您不想要占位符而只想将光标放在两个位置,它看起来像这样:

{ ...
        "contents": "console.log('$1', $1)"
    ...
}

让我知道这是否适合您。

于 2015-07-11T00:40:44.223 回答