开发者

Vim mapping to copy all text in visual mode

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 :-).开发者_StackOverflow社区 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


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>


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜