Skip to content

Commit

Permalink
fixes VSCodeVim#8783 add easymotionSearchLines
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryTSZ committed Jun 28, 2024
2 parents 35b9b9b + 3130178 commit 662ad36
Show file tree
Hide file tree
Showing 7 changed files with 142 additions and 98 deletions.
13 changes: 7 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ VSCodeVim can be installed via the VS Code [Marketplace](https://marketplace.vis
To enable key-repeating, execute the following in your Terminal, log out and back in, and then restart VS Code:

```sh
$ defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false # For VS Code
$ defaults write com.microsoft.VSCodeInsiders ApplePressAndHoldEnabled -bool false # For VS Code Insider
$ defaults write com.vscodium ApplePressAndHoldEnabled -bool false # For VS Codium
$ defaults write com.microsoft.VSCodeExploration ApplePressAndHoldEnabled -bool false # For VS Codium Exploration users
$ defaults delete -g ApplePressAndHoldEnabled # If necessary, reset global default
defaults write com.microsoft.VSCode ApplePressAndHoldEnabled -bool false # For VS Code
defaults write com.microsoft.VSCodeInsiders ApplePressAndHoldEnabled -bool false # For VS Code Insider
defaults write com.vscodium ApplePressAndHoldEnabled -bool false # For VS Codium
defaults write com.microsoft.VSCodeExploration ApplePressAndHoldEnabled -bool false # For VS Codium Exploration users
defaults delete -g ApplePressAndHoldEnabled # If necessary, reset global default
```

We also recommend increasing Key Repeat and Delay Until Repeat settings in _System Preferences -> Keyboard_.
Expand Down Expand Up @@ -146,7 +146,7 @@ These settings are specific to VSCodeVim.
| vim.handleKeys | Delegate configured keys to be handled by VS Code instead of by the VSCodeVim extension. Any key in `keybindings` section of the [package.json](https://github.com/VSCodeVim/Vim/blob/master/package.json) that has a `vim.use<C-...>` in the `when` argument can be delegated back to VS Code by setting `"<C-...>": false`. Example: to use `ctrl+f` for find (native VS Code behavior): `"vim.handleKeys": { "<C-f>": false }`. | String | `"<C-d>": true`<br /> `"<C-s>": false`<br /> `"<C-z>": false` |
| vim.overrideCopy | Override VS Code's copy command with our own, which works correctly with VSCodeVim. If cmd-c/ctrl-c is giving you issues, set this to false and complain [here](https://github.com/Microsoft/vscode/issues/217). | Boolean | false |
| vim.useSystemClipboard | Use the system clipboard register (`*`) as the default register | Boolean | false |
| vim.killRingMax | Maximum length of kill ring before oldest elements are thrown away. | Number | 120 |
| vim.killRingMax | Maximum length of kill ring before oldest elements are thrown away. | Number | 120 |
| vim.searchHighlightColor | Background color of non-current search matches | String | `findMatchHighlightBackground` ThemeColor |
| vim.searchHighlightTextColor | Foreground color of non-current search matches | String | None |
| vim.searchMatchColor | Background color of current search match | String | `findMatchBackground` ThemeColor |
Expand Down Expand Up @@ -562,6 +562,7 @@ Based on [vim-easymotion](https://github.com/easymotion/vim-easymotion) and conf
| vim.easymotionMarkerFontWeight | The font weight used for the marker text. | String | 'bold' |
| vim.easymotionKeys | The characters used for jump marker name | String | 'hklyuiopnm,qwertzxcvbasdgjf;' |
| vim.easymotionJumpToAnywhereRegex | Custom regex to match for JumpToAnywhere motion (analogous to `Easymotion_re_anywhere`) | String | `\b[A-Za-z0-9]\|[A-Za-z0-9]\b\|_.\|#.\|[a-z][A-Z]` |
| vim.easymotionSearchLines | Set the number of lines for the easymotion search. | Number | 100 |

Once easymotion is active, initiate motions using the following commands. After you initiate the motion, text decorators/markers will be displayed and you can press the keys displayed to jump to that position. `leader` is configurable and is `\` by default.

Expand Down
15 changes: 10 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -753,6 +753,11 @@
"description": "Regex matches for JumpToAnywhere motion.",
"default": "\\b[A-Za-z0-9]|[A-Za-z0-9]\\b|_.|#.|[a-z][A-Z]"
},
"vim.easymotionSearchLines": {
"type": "number",
"description": "Set the number of lines for the easymotion search.",
"default": 100
},
"vim.replaceWithRegister": {
"type": "boolean",
"markdownDescription": "Enable the [ReplaceWithRegister](https://github.com/vim-scripts/ReplaceWithRegister) plugin for Vim.",
Expand Down Expand Up @@ -1368,9 +1373,9 @@
"@types/diff": "5.2.1",
"@types/diff-match-patch": "1.0.36",
"@types/glob": "8.1.0",
"@types/lodash": "4.17.5",
"@types/mocha": "10.0.6",
"@types/node": "18.19.34",
"@types/lodash": "4.17.6",
"@types/mocha": "10.0.7",
"@types/node": "18.19.39",
"@types/parsimmon": "1.10.9",
"@types/sinon": "17.0.3",
"@types/vscode": "1.74.0",
Expand All @@ -1393,14 +1398,14 @@
"husky": "^9.0.0",
"lint-staged": "^15.0.0",
"minimist": "1.2.8",
"mocha": "10.4.0",
"mocha": "10.5.2",
"plugin-error": "2.0.1",
"prettier": "3.3.2",
"sinon": "18.0.0",
"ts-loader": "9.5.1",
"typescript": "5.4.5",
"vsce": "2.15.0",
"webpack": "5.92.0",
"webpack": "5.92.1",
"webpack-cli": "5.1.4",
"webpack-merge": "5.10.0",
"webpack-stream": "7.0.0"
Expand Down
4 changes: 2 additions & 2 deletions src/actions/plugins/easymotion/easymotion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -150,9 +150,9 @@ export class EasyMotion implements IEasyMotion {
if (
(options.min && pos.isBefore(options.min)) ||
(options.max && pos.isAfter(options.max)) ||
Math.abs(pos.line - position.line) > 100
Math.abs(pos.line - position.line) > configuration.easymotionSearchLines
) {
// Stop searching after 100 lines in both directions
// Stop searching after 100(default) lines in both directions
result = regex.exec(line);
} else {
// Update cursor index to the marker on the right side of the cursor
Expand Down
1 change: 1 addition & 0 deletions src/configuration/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ class Configuration implements IConfiguration {
easymotionMarkerFontWeight = 'bold';
easymotionKeys = 'hklyuiopnm,qwertzxcvbasdgjf;';
easymotionJumpToAnywhereRegex = '\\b[A-Za-z0-9]|[A-Za-z0-9]\\b|_.|#.|[a-z][A-Z]';
easymotionSearchLines = 100;

flash = {
enable: true,
Expand Down
2 changes: 2 additions & 0 deletions src/configuration/iconfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,8 @@ export interface IConfiguration {
easymotionDimBackground: boolean;
easymotionMarkerFontWeight: string;
easymotionKeys: string;
easymotionJumpToAnywhereRegex: string;
easymotionSearchLines: number;

/**
* Timeout in milliseconds for remapped commands.
Expand Down
2 changes: 2 additions & 0 deletions test/testConfiguration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ export class Configuration implements IConfiguration {
easymotionDimBackground = true;
easymotionMarkerFontWeight = 'bold';
easymotionKeys = 'hklyuiopnm,qwertzxcvbasdgjf;';
easymotionJumpToAnywhereRegex = '\\b[A-Za-z0-9]|[A-Za-z0-9]\\b|_.|#.|[a-z][A-Z]';
easymotionSearchLines = 100;

flash: IFlashConfiguration = {
enable: false,
Expand Down
Loading

0 comments on commit 662ad36

Please sign in to comment.