问题
This is currently how I copy code from an editor to a search field in VS code using vscodevim.
- Select text in editor somehow
- 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 - Press
Ctrl+Shift+F
to open the search field - 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?
回答1:
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:
- Select text
"+y
(you can create a shortcut for this combination if you want)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>"
).
来源:https://stackoverflow.com/questions/55302116/how-to-efficiently-copy-code-from-editor-to-search-field-in-vs-code-using-vscode