2

This is currently how I copy code from an editor to a search field in VS code using vscodevim.

  1. Select text in editor somehow
  2. Right click to open up the contextual menu (since pressing Ctrl+C does not seem to work on Ubuntu, even when in input mode, and 'p' does not work in the search field) and click copy
  3. Press Ctrl+Shift+F to open the search field
  4. Press Ctrl+V

I'm pretty sure this is not how copying from an editor to search field is intended to work. It it the steps 1 and 2 I would like to change to something better.

What is a more efficient and vim-like sequence?

user1283776
  • 12,822
  • 32
  • 103
  • 190

1 Answers1

0

If you want to search for the word under the cursor

Ctrl-F will do the trick.

Or you can use Vim's * command, which effectively does the same, but jumps to the next occurrence right away by default.

Otherwise

If you need to use the search field for whatever reason, then the standard Vim way to copy stuff to the clipboard works, so you can yank into the * or + registers. The steps will then be:

  1. Select text
  2. "+y (you can create a shortcut for this combination if you want)
  3. Ctrl-Shift-F, Ctrl-V

See also: How to make vim paste from (and copy to) system's clipboard?.

Having said that, the more obvious approach might be to use Vim's built-in search features, so after selecting the text, the remaining steps would be y: (yanking selection to the default register and opening the command-line) then / or ? (search forward or backward), then <C-v> (pasting the yanked selection to the command-line - this works only in the VSCode plugin, while in Vim you should use <C-r>").

pamacs
  • 100
  • 6
  • except that... ctrl-V does nothing here. this is true for both the global search (ctrl-shift-F) and search in currently open file (ctrl-F). right-click and select "paste" works. charming. EDIT: I'm not using vscodevim, just plain vscode – Marc Nov 10 '20 at 14:57