How to efficiently copy code from editor to search field in VS Code using vscodevim?

☆樱花仙子☆ 提交于 2021-02-10 12:21:32

问题


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?


回答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:

  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>").



来源:https://stackoverflow.com/questions/55302116/how-to-efficiently-copy-code-from-editor-to-search-field-in-vs-code-using-vscode

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!