Vim 映射以在可视模式下复制所有文本

发布于 2024-12-09 15:25:33 字数 658 浏览 0 评论 0原文

我想在可视模式下映射 ctrl+a 以选择并复制当前缓冲区中的所有文本。

基本思想是执行:%y*(将所有缓冲区复制到剪贴板)。因此,映射应该是: xmap :%y* (xmap 仅适用于可视模式)

但是,每当我运行此映射时,都会显示此输出:

E492: Not an editor command: '<,'>%y*

而且,我认为 Vim 是正确的:-)。在视觉模式下,按“:”,使命令行显示那些令人惊讶的字符:

":'<,'>" 

我可以找到此模式('<,'>)的唯一相关信息是那一个: http://vimdoc.sourceforge.net/htmldoc/cmdline.html#v_< /a>: (这对我没有帮助)。

问题:我做错什么了吗(配置...)?是否有另一个答案可以满足我的需求(将所有文本复制到剪贴板)?

我运行的是 Vim 7.3,我只在 vimrc 中设置了 no兼容

感谢您的帮助, 汤姆

I would like to map ctrl+a in visual mode to select and copy all text from the current buffer.

The basic idea is to execute: %y* (copy all buffer to clipboard). So, the mapping should be: xmap :%y* (xmap for visual mode only)

However, whenever I run this mapping, this output is shown:

E492: Not an editor command: '<,'>%y*

And, I think Vim is right :-). When in visual mode, pressing the ":", makes the cmd-line show those surprising characters:

":'<,'>" 

The only relevant piece of info where I could find this pattern ('<,'>) is that one: http://vimdoc.sourceforge.net/htmldoc/cmdline.html#v_:
(and it didn't help me).

Question: Am I doing something wrong (configuration...) ? Is there another answer to my need (copy all text to clipboard) ?

I am running Vim 7.3 and I only set nocompatible in my vimrc

Thanks for your help,
Tom

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

很糊涂小朋友 2024-12-16 15:25:33

使用:

xnoremap <whatever> :<c-u>%y*<return>

附加的ctrl-u删除命令行直到光标。

来自 vim 参考:

                            *c_CTRL-U*
CTRL-U  Remove all characters between the cursor position and
        the beginning of the line.  Previous versions of vim
        deleted all characters on the line.  If that is the
        preferred behavior, add the following to your .vimrc: >
        :cnoremap <C-U> <C-E><C-U>

Use:

xnoremap <whatever> :<c-u>%y*<return>

The additional ctrl-u erases the command line till the cursor.

From vim reference:

                            *c_CTRL-U*
CTRL-U  Remove all characters between the cursor position and
        the beginning of the line.  Previous versions of vim
        deleted all characters on the line.  If that is the
        preferred behavior, add the following to your .vimrc: >
        :cnoremap <C-U> <C-E><C-U>
转身以后 2024-12-16 15:25:33

使用以下映射:

nmap <C-A> ggVGy

它会拉出所有当前文件。顺便说一句,我不确定这是否正是你所想的。我不明白你为什么想要视觉映射。

Use the following mapping:

nmap <C-A> ggVGy

It yanks all the current file. By the way, I'm not sure it's exactly what you what. I don't understand why you want a visual mapping.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文