Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/antfu/vscode-smart-clicks

Smart selection with double clicks for VS Code.
https://github.com/antfu/vscode-smart-clicks

vscode vscode-extension

Last synced: about 19 hours ago
JSON representation

Smart selection with double clicks for VS Code.

Awesome Lists containing this project

README

        



Smart Clicks VS Code


Visual Studio Marketplace Version


Smart selection with double clicks for VS Code.

GIF Demo

## Usage

Double clicks on the code.

## Rules

#### [`bracket-pair`](https://github.com/antfu/vscode-smart-clicks/blob/main/src/rules/bracket-pair.ts)

Pair to inner content of brackets.

```js

(foo, bar)
└──────┘
```

#### [`dash`](https://github.com/antfu/vscode-smart-clicks/blob/main/src/rules/dash.ts)

`-` to identifier.

```css

foo-bar
└─────┘
```

#### [`html-attr`](https://github.com/antfu/vscode-smart-clicks/blob/main/src/rules/html-attr.ts)

`=` to HTML attribute.

```html


└─────────┘
```

#### [`html-element`](https://github.com/antfu/vscode-smart-clicks/blob/main/src/rules/html-element.ts)

`<` to the entire element.

```html


└────────────────────┘
```

#### [`html-tag-pair`](https://github.com/antfu/vscode-smart-clicks/blob/main/src/rules/html-tag-pair.ts)

Open and close tags of a HTML element.

```html


└─┘ └─┘
```

#### [`js-arrow-fn`](https://github.com/antfu/vscode-smart-clicks/blob/main/src/rules/js-arrow-fn.ts)

`=>` to arrow function.

```js

(a, b) => a + b
└─────────────┘
```

#### [`js-assign`](https://github.com/antfu/vscode-smart-clicks/blob/main/src/rules/js-assign.ts)

`=` to assignment.

```js

const a = []
└──────────┘

class B {

b = 1;
└────┘

ba = () => {};
└────────────┘
}
```

#### [`js-block`](https://github.com/antfu/vscode-smart-clicks/blob/main/src/rules/js-block.ts)

Blocks like `if`, `for`, `while`, etc. in JavaScript.

```js

function () { }
└─────────────────┘
```

```js

import { ref } from 'vue'
└───────────────────────┘
```

This rule is _disabled_ by default.

#### [`js-colon`](https://github.com/antfu/vscode-smart-clicks/blob/main/src/rules/js-colon.ts)

`:` to the value.

```js

{ foo: { bar } }
└─────┘
```

#### [`jsx-tag-pair`](https://github.com/antfu/vscode-smart-clicks/blob/main/src/rules/jsx-tag-pair.ts)

Matches JSX elements' start and end tags.

```jsx

(Hi)
└───────┘ └───────┘
```

## Configuration

All the rules are enabled by default. To disable a specific rule, set the rule to `false` in `smartClicks.rules` of your VS Code settings:

```jsonc
// settings.json
{
"smartClicks.rules": {
"dash": false,
"html-element": false,
"js-block": true
}
}
```

## Commands

| ID | Description |
| --------------------- | ------------------------------------------------------------------- |
| `smartClicks.trigger` | Trigger Smart Clicks in current cursor position without mouse click |

Usage examples:

1. Command palette

Invoke the command palette by typing `Ctrl+Shift+P` and then typing `Smart Clicks: Trigger`.

2. Keyboard shortcuts

```jsonc
// keybindings.json
{
"key": "ctrl+alt+c",
"command": "smartClicks.trigger",
"when": "editorTextFocus"
}
```

3. Vim keybindings ([VSCodeVim](https://marketplace.visualstudio.com/items?itemName=vscodevim.vim) is needed)

```jsonc
// settings.json
{
"vim.normalModeKeyBindings": [
{
"before": ["leader", "c"],
"commands": ["smartClicks.trigger"],
}
]
}
```

## Sponsors





## Credits

Inspired by [HBuilderX](https://www.dcloud.io/hbuilderx.html), initiated by [恐粉龙](https://space.bilibili.com/432190144).

## License

[MIT](./LICENSE) License © 2022 [Anthony Fu](https://github.com/antfu)