Cómo copiar texto arrancado al símbolo del sistema VI


Quiero saber si hay alguna manera por la cual puedo pegar texto tirado a la ventana de comandos. Por ejemplo. si he tirado una palabra y quiero grep en algún lugar no puedo simplemente pegar la palabra usando 'p'. Sin embargo, si lo copio en el portapapeles, Shift-Insert pegará lo mismo.

¿Hay algún ajuste disponible que me permita pegar texto arrancado en el símbolo del sistema de vim? Estoy usando gvim en Windows.

 105
vim
Author: Canopus, 2009-05-25

7 answers

Intenta usar

<ctrl+r>"

Donde " significa default register.

 152
Author: Mykola Golubyev,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-05-25 12:28:34

<C-R>" Pegará el búfer predeterminado. Alternativamente, puede usar q: para abrir un búfer para el siguiente comando. try :help q:

 35
Author: soulmerge,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-05 13:07:30

En modo normal, presione :, luego ctrl-r y luego ".

 13
Author: Rook,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-12 01:05:32

Para ahorrarle un paso de tirar, si su cursor está en la palabra que desea usar en Ex, use:

 <ctl-r><ctl-w>

Esto evita tirar de pegar en la línea de comandos; en su lugar, se pega la palabra debajo del cursor directamente en la línea de comandos. Por ejemplo:

:%s/<ctl-r><ctl-w>/foo/g
 10
Author: gregory,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-11-09 07:07:04

Si es solo una palabra que desea copiar, puede usar <C-r><C-w>

  1. Coloque el cursor sobre la palabra
  2. Entonces puedes escribir algo como :vim <C-r><C-w> *
 5
Author: SysCoder,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2013-06-02 02:49:24

Puede tirar del portapapeles usando el búfer llamado *. Por ejemplo, esto copiará la línea actual al portapapeles:

"*yy

Así que puede copiar una línea usando esto, y luego pegarla con shift-insert en la línea de comandos.

Del mismo modo, puede pegar desde el portapapeles de esta manera:

"*p
 3
Author: Nathan Fellman,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2009-05-25 12:32:39

El portapapeles es +, al menos en Mac. Entonces escribirías "+yy para tirar una línea al portapapeles, y "+p para pegar. Aunque siempre se puede usar Command-C y Command-V.

 2
Author: ABC,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2012-06-26 19:40:36