basic vim usage

93 views
Skip to first unread message

vicky b

unread,
Nov 8, 2012, 6:23:20 AM11/8/12
to v...@vim.org
I have started to learn vim in this modern enviroment where gui takes prefers , one thing that still me back to other editors is the ease with which we can  copy and paste , can anybody help me out with safe effect in vim or any thing of that sort

--
Thanks & Regards
 Vickyb



Marco

unread,
Nov 8, 2012, 7:29:30 AM11/8/12
to vim...@googlegroups.com
2012-11-08 vicky b:

> one thing that still me back to other editors is the ease with
> which we can copy and paste , can anybody help me out with safe
> effect in vim or any thing of that sort

You can

set clipboard=unnamed

to use the system clipboard for yank and paste operations. With this
option you can easily copy and paste within vim and to/from other
applications. For further information see

:h 'clipboard'


Marco


Karthick Gururaj

unread,
Nov 8, 2012, 7:35:51 AM11/8/12
to vim_use, v...@vim.org
On Thu, Nov 8, 2012 at 4:53 PM, vicky b <vicky...@gmail.com> wrote:
I have started to learn vim in this modern enviroment where gui takes prefers , one thing that still me back to other editors is the ease with which we can  copy and paste , can anybody help me out with safe effect in vim or any thing of that sort
If you are using gvim, you have the option of clicking on "Edit" -> "Copy" and "Edit" -> "Paste". You need to select some text first obviously, before copy. Selection can be done with mouse. Using CTRL-C and CTRL-V might also work for copy/paste - whether it does work or not depends on a few factors.

It that the answer you were looking for?

Also, if GUI is what you want to work with, vim may not be worth looking at. Just my opinion.

vicky b

unread,
Nov 8, 2012, 7:37:42 AM11/8/12
to vim...@googlegroups.com, v...@vim.org
no  i dont want to use GUI , i want to use vim not gvim  how can copy and paste with ease in vim


--
You received this message from the "vim_use" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

Fredrik Andersson

unread,
Nov 8, 2012, 7:43:33 AM11/8/12
to vim...@googlegroups.com, v...@vim.org
On Thu, Nov 8, 2012 at 1:37 PM, vicky b <vicky...@gmail.com> wrote:
no  i dont want to use GUI , i want to use vim not gvim  how can copy and paste with ease in vim

y for yank (copy)
p for paste

Use the * register to yank/paste to/from the system clipboard.

This should be covered in the vimtutorial, run vimtutor if you have not done so yet.
 

Marcin Szamotulski

unread,
Nov 8, 2012, 8:03:50 AM11/8/12
to vim...@googlegroups.com
On 13:43 Thu 08 Nov , Fredrik Andersson wrote:
> On Thu, Nov 8, 2012 at 1:37 PM, vicky b <vicky...@gmail.com> wrote:
>
> > no i dont want to use GUI , i want to use vim not gvim how can copy and
> > paste with ease in vim
>
>
> y for yank (copy)
> p for paste
>
> Use the * register to yank/paste to/from the system clipboard.
>
> This should be covered in the vimtutorial, run vimtutor if you have not
> done so yet.

Hi,

You can also paste from a register in the insert mode, see ":help i^r".
For example CTRL-R0 in insert mode will paste the recent yank. There is
also ":help i^r^r" (e.g. CTRL-R_CTRL-R) which puts the content of the
register literally. This will differ from ^r if there is a backspace in
the register: using ^r will delete like backspace does, ^r^r will put
the backspace literally into the buffer.

Best regards,
Marcin

Phil Dobbin

unread,
Nov 8, 2012, 8:13:39 AM11/8/12
to vim...@googlegroups.com
Fredrik Andersson wrote:
>
>
> On Thu, Nov 8, 2012 at 1:37 PM, vicky b <vicky...@gmail.com
> <mailto:vicky...@gmail.com>> wrote:
>
> no i dont want to use GUI , i want to use vim not gvim how can
> copy and paste with ease in vim
>
>
> y for yank (copy)
> p for paste
>
> Use the * register to yank/paste to/from the system clipboard.
>
> This should be covered in the vimtutorial, run vimtutor if you have not
> done so yet.

Also, depending on which term you are using (this works in
gnome-terminal & konsole), you can select the text & then use
ctrl-shift-c to copy & ctrl-shift-p to paste if you get really stuck
and/or confused initially. And that works across all consoles you have
open, local & remote.

Cheers,

Phil...


> On Thu, Nov 8, 2012 at 6:05 PM, Karthick Gururaj
> <karthick...@gmail.com <mailto:karthick...@gmail.com>> wrote:
>
>
> On Thu, Nov 8, 2012 at 4:53 PM, vicky b <vicky...@gmail.com
> <mailto:vicky...@gmail.com>> wrote:
>
> I have started to learn vim in this modern enviroment where
> gui takes prefers , one thing that still me back to other
> editors is the ease with which we can copy and paste , can
> anybody help me out with safe effect in vim or any thing of
> that sort
>
> If you are using gvim, you have the option of clicking on "Edit"
> -> "Copy" and "Edit" -> "Paste". You need to select some text
> first obviously, before copy. Selection can be done with mouse.
> Using CTRL-C and CTRL-V might also work for copy/paste - whether
> it does work or not depends on a few factors.
>
> It that the answer you were looking for?
>
> Also, if GUI is what you want to work with, vim may not be worth
> looking at. Just my opinion.

--
But masters, remember that I am an ass.
Though it be not written down,
yet forget not that I am an ass.

Wm. Shakespeare - Much Ado About Nothing

signature.asc

stosss

unread,
Nov 8, 2012, 8:22:38 AM11/8/12
to vim...@googlegroups.com
On Thu, Nov 8, 2012 at 6:23 AM, vicky b <vicky...@gmail.com> wrote:
> I have started to learn vim in this modern enviroment where gui takes
> prefers , one thing that still me back to other editors is the ease with
> which we can copy and paste , can anybody help me out with safe effect in
> vim or any thing of that sort
>

Here is a cool feature that some Linux users don't know about.

Linux has the ability to copy without using a copy command. Simply
high lite the text you want and then place the curse where you want to
paste that text and just click the middle mouse button. This is
available system wide on Linux maybe Mac too but no at all on windows.

In gVim you have to be in insert mode for it to work coming from
another app to gVim. Inside gVim from one place to another you can be
in command mode and do it. This will work in Vim in the terminal too.

Shlomi Fish

unread,
Nov 8, 2012, 8:30:13 AM11/8/12
to v...@vim.org
Hi Vicky,

On Thu, 8 Nov 2012 18:07:42 +0530
vicky b <vicky...@gmail.com> wrote:

> no i dont want to use GUI , i want to use vim not gvim how can copy and
> paste with ease in vim
>

if you're interested in copying and pasting within Vim itself, you can use the
register yanking/deleting/pasting commands, like y, d, c, p and P. If you're
interested in copying to the system buffer, you can prefix these commands with
"+ (double-quotes-plus) or "* (double-quotes-asterisk). For more information,
read ":help change.txt" in Vim (without the quotes).

Regards,

Shlomi Fish

>
> On Thu, Nov 8, 2012 at 6:05 PM, Karthick Gururaj <karthick...@gmail.com
> > wrote:
>
> >
> > On Thu, Nov 8, 2012 at 4:53 PM, vicky b <vicky...@gmail.com> wrote:
> >
> >> I have started to learn vim in this modern enviroment where gui takes
> >> prefers , one thing that still me back to other editors is the ease with
> >> which we can copy and paste , can anybody help me out with safe effect in
> >> vim or any thing of that sort
> >
> > If you are using gvim, you have the option of clicking on "Edit" -> "Copy"
> > and "Edit" -> "Paste". You need to select some text first obviously, before
> > copy. Selection can be done with mouse. Using CTRL-C and CTRL-V might also
> > work for copy/paste - whether it does work or not depends on a few factors.
> >
> > It that the answer you were looking for?
> >
> > Also, if GUI is what you want to work with, vim may not be worth looking
> > at. Just my opinion.
> >
> > --
> > You received this message from the "vim_use" maillist.
> > Do not top-post! Type your reply below the text you are replying to.
> > For more information, visit http://www.vim.org/maillist.php
> >
>
>
>



--
-----------------------------------------------------------------
Shlomi Fish http://www.shlomifish.org/
Chuck Norris/etc. Facts - http://www.shlomifish.org/humour/bits/facts/

The English Wikipedia: now you don't see it — now you do.

Please reply to list if it's a mailing list post - http://shlom.in/reply .

Suresh Govindachar

unread,
Nov 8, 2012, 8:40:29 AM11/8/12
to vim...@googlegroups.com, sto...@gmail.com
On 11/8/2012 5:22 AM, stosss wrote:

> Linux has the ability to copy without using a copy command. Simply
> high lite the text you want and then place the curse where you want to
> paste that text and just click the middle mouse button. This is
> available system wide on Linux maybe Mac too but no at all on windows.

That actually works on my Windows gvim: In normal mode: highlight some
text, move mouse to some place and press middle button: stuff that was
highlighted gets pasted.

Also, highlight some text in normal mode, hit "<esc>", go to some other
place (perhaps using ijkl keys), hit "p" (to put the highlighted text at
current location).

--Suresh

Tim Chase

unread,
Nov 8, 2012, 9:05:33 AM11/8/12
to v...@vim.org, vicky b
On 11/08/12 05:23, vicky b wrote:
> I have started to learn vim in this modern enviroment where gui
> takes prefers , one thing that still me back to other editors is
> the ease with which we can copy and paste , can anybody help me
> out with safe effect in vim or any thing of that sort

As others have mentioned, you might want to go through the vimtutor
that is available when vim is installed.

However, it's helpful to know that the "y"ank, "d"elete, "c"hange,
and "s"ubstitute commands all alter the contents of "registers".
The p/P commands are used to paste contents of those registers in
Normal mode, and (as mentioned elsewhere, control+R can be used to
insert register contents in Insert mode). These are lots of
registers in vim, unlike Windows and Mac, where you usually only
have one system clipboard. By default Vim operates on the unnamed
register, so when you yank/delete/change/substitute, it puts the
thing in this scratch register. By default when you paste, it uses
this register. However, you can prefix the
yank/delete/change/substitute/paste commands by naming the register
you want to operate on, such as

"by3w

will yank 3 words into the "b" register, then

"bp

will paste the contents of the "b" register at some other location.
You can list the contents of registers with the

:reg

command. There are registers for filenames, expression evaluation,
most recent deletions, most recent yank, etc. If you want to
interchange with other applications, you may be interested in the
"system clipboard" register (or the "selection" register, if you're
running on X/Linux/BSD) which is effectively what other applications
will refer to as *the* clipboard. You *can* set 'clipboard' to
include "unnamed" as one of its options, but after trying it for an
afternoon, I found it drove me absolutely bonkers and I turned it
right back off.

Reading up at

:help registers

to learn LOTS more on them.

-tim





Gary Johnson

unread,
Nov 8, 2012, 3:43:14 PM11/8/12
to vim...@googlegroups.com
Yes, this does work very well.

With a version of vim that has +clipboard, +X11 and +xterm_clipboard
features and a ~/.vimrc that has

set mouse=a
set clipboard^=unnamed

you can copy and paste between different instances of vim, gvim and
other applications running in Windows or in X11 on Linux using any
of the techniques discussed here, including the traditional X11
left-click-to-copy, middle-click-to-paste, in normal and insert
modes.

One thing to be careful of: some Linux distributions build separate
binaries for vim and gvim and their vim build does not include
support for X11 or the clipboard. So make sure you are using a vim
with that support. A workaround for this is to use "gvim -v". This
will execute the gvim binary, giving you X11 support, but as a
terminal application, i.e. just like "vim".

Having said all that, I will agree with Tim that including "unnamed"
in 'clipboard' may not be what you want. The advantage is that
everything you select goes to the clipboard. The disadvantage is
that everything you select goes to the clipboard. The result is
that it either "just works" or drives you nuts, depending on your
expectations.

HTH,
Gary

Reply all
Reply to author
Forward
0 new messages