Roger
Roger

Reputation: 361

Search backward in visual studio code from current position

Suppose I have a very loooong file with all my libraries and its functions (can't change it, that's what I have to work with), all in one file, e.g.:

    [library1
    function 1
    blablablah1
    
    
    [library2
...
    function 2
    blablablah2

I want to find the closest [library...] line, to guess which library contains my current cursor line:

For example, if I have the cursor in the line "blablablah2", and do a search (ctrl+f), and start typing "[lib", the cursor immediately goes to "[library1" because it always start searching from the beginning of the file. I want that, when I start typing, the cursor don't start moving until I press the "up" arrow to search backwards... so I find the [library2] line

Thanks in advance,

Roger

Upvotes: 3

Views: 1061

Answers (2)

Mark
Mark

Reputation: 182931

Disable this setting:

Editor > Find: Cursor Move On Type

// Controls whether the cursor should jump to find matches while typing. "editor.find.cursorMoveOnType": false,

Now the cursor will not jump to matches as you type.

Upvotes: 2

rioV8
rioV8

Reputation: 28848

You can use the extension Select By.

Add this to your keybindings.json:

{
    "key": "ctrl+shift+f6",  // or any other key combo
    "when": "editorTextFocus",
    "command": "moveby.regex",
    "args": {
      "ask": true,
      "properties": ["prev", "start"]
    }
  }

You enter a regular expression (escape a few characters if needed).

Upvotes: 1

Related Questions