Wierdness in vim

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Wierdness in vim

a joeiam
Greetings

Have been using vi for a while but more as a minor tool just used in system
manipulation. Found a useful tool called ledger-cli and have therefore been using much more of both vim and gvim to generate the plain text files.Using vim 8.0.34. on a Debian jessie vm.

Issue:working in a file with about 6800 lines I find an error. Need to add two lines to one 'section'. Used +y to yank and then used +GP to place. Was absolutely
unable to place the lines. Instead the 2 lines were place at the end of the document. Used +GP a couple more times not understanding why the 2 lines were not placed and then I looked at the doc.I had gone from 6814 lines to 12 877 lines and all of the lines were the 2 yanked (with a blank line before and after each iteration).

I have read the manual a few times before this and more after and I just cannot understand why +GP won't let me place lines anywhere I am asking. Maybe I'm too used to the ctrl-c and ctrl-v too much (using wysiwyg programs for 30 years or so).

Is there anyone who can explain the limitations and/or the exact functions of both +y and +GP - - - - please?

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Wierdness in vim

Ben Fritz
On Thursday, March 16, 2017 at 7:14:09 AM UTC-5, a joeiam wrote:

> Greetings
>
> Have been using vi for a while but more as a minor tool just used in system
> manipulation. Found a useful tool called ledger-cli and have therefore been using much more of both vim and gvim to generate the plain text files.Using vim 8.0.34. on a Debian jessie vm.
>
> Issue:working in a file with about 6800 lines I find an error. Need to add two lines to one 'section'. Used +y to yank and then used +GP to place. Was absolutely
> unable to place the lines. Instead the 2 lines were place at the end of the document. Used +GP a couple more times not understanding why the 2 lines were not placed and then I looked at the doc.I had gone from 6814 lines to 12 877 lines and all of the lines were the 2 yanked (with a blank line before and after each iteration).
>
> I have read the manual a few times before this and more after and I just cannot understand why +GP won't let me place lines anywhere I am asking. Maybe I'm too used to the ctrl-c and ctrl-v too much (using wysiwyg programs for 30 years or so).
>
> Is there anyone who can explain the limitations and/or the exact functions of both +y and +GP - - - - please?
Where are you entering these commands? In normal mode "+y" is not a full command (+ goes down a line, then y is an incomplete yank command), and "+GP" doesn't make much sense (go down a line, go to end of file, paste before). If those are supposed to be ex commands or were specified from the command-line when launching Vim, then "+GP" isn't a valid command at all.

I suspect what might be happening is that if your file is folded on launching Vim, then a yank command will copy all text within the fold, and "GP" (from normal mode) will go to the end of the file and paste all that text. But as stated above the exact commands you gave don't actually do much of anything.

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Wierdness in vim

Tim Chase
In reply to this post by a joeiam
On 2017-03-16 05:05, a joeiam wrote:
> Issue:working in a file with about 6800 lines I find an error. Need
> to add two lines to one 'section'. Used +y to yank and then used
> +GP to place. Was absolutely unable to place the lines. Instead the
> 2 lines were place at the end of the document.

It looks like you're trying to yank to the system clipboard.  For
that, you want

  "+y

(i.e., include the double-quote before hand).  The yanking sequence
as you describe it currently goes to the beginning of the next line

  :help +

and then begins a yank, but leaves you in operator-pending mode as
it's expecting a motion to specify where you want to yank to.

If you've recently changed your vim, make sure that you're using one
that has been built with clipboard support.  To do that, issue

  :version

and look for "+clipboard" instead of "-clipboard".  If you have
"-clipboard", you're likely running what some distros call "vim-tiny"
or an alternate vi such as nvi, stevie, or elvis.

If you're really trying to yank two lines into the unnamed register,
you need to specify the motion after the "y" by doing

  y+

which can also be written as

  yj

or

  2Y

Likewise, when you go to paste, your "+GP" translates as

  +    Go to the beginning of the next line
  G    Wait, actually go to the bottom of the file
  P    Paste the most recently-yanked thing before the cursor

If you want to paste from the system clipboard, again, you need to
prefix the register reference with the double-quote:

  "+GP

That all said, unless you actually need the yank put on the system
clipboard, vim has a bunch of named registers if you want to keep the
content around, and defaults to the "unnamed" register.  So you may
be good with just doing

  yy

to yank the row (or "y+" to yank two rows, or "yap" to yank the
blank-line-delimited block), move to your destination, and

  p

to paste the content.  Note that those are all lowercase.  There is a
"gp" command, but the (capital) "G" you're issuing is what moves you
to the end of your file.

> Used +GP a couple more times not understanding why the 2 lines were
> not placed and then I looked at the doc.I had gone from 6814 lines
> to 12 877 lines and all of the lines were the 2 yanked (with a
> blank line before and after each iteration).

I suspect something got omitted and you ended up yanking from your
current location to the end of the file, and then pasting that
content. If your cursor was at the beginning of the file to start,
that would double the size of the file.

-tim


--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Wierdness in vim

Gary Johnson-4
In reply to this post by a joeiam
On 2017-03-16, a joeiam wrote:

> Greetings
>
> Have been using vi for a while but more as a minor tool just used
> in system manipulation. Found a useful tool called ledger-cli and
> have therefore been using much more of both vim and gvim to
> generate the plain text files.Using vim 8.0.34. on a Debian jessie
> vm.
>
> Issue:working in a file with about 6800 lines I find an error.
> Need to add two lines to one 'section'. Used +y to yank and then
> used +GP to place. Was absolutely unable to place the lines.
> Instead the 2 lines were place at the end of the document. Used
> +GP a couple more times not understanding why the 2 lines were not
> placed and then I looked at the doc.I had gone from 6814 lines to
> 12 877 lines and all of the lines were the 2 yanked (with a blank
> line before and after each iteration).
>
> I have read the manual a few times before this and more after and
> I just cannot understand why +GP won't let me place lines anywhere
> I am asking. Maybe I'm too used to the ctrl-c and ctrl-v too much
> (using wysiwyg programs for 30 years or so).
>
> Is there anyone who can explain the limitations and/or the exact
> functions of both +y and +GP - - - - please?

There are no commands +y and +GP so I don't know how to directly
answer your question.

I recommend that you run the vimtutor program to properly learn the
movement, copy and paste commands.  That would solve these and
probably other misunderstandings.  See

    :help vimtutor

+ is a motion command.  It moves the cursor one line down.  My guess
is that you wanted to yank into the + register.  To specify the
+ register you need to precede the + with a ".  See

    :help +
    :help registers
    :help "+

For most simple copy-and-paste operations, you don't need to specify
a specific register.  Just use the default, unnamed register.

y is a yank command, but in normal mode it must be followed by a
motion command to complete the command.  The character

    y

is an incomplete command.  The next character will be interpreted
as a motion command which will tell Vim what to yank.  See

    :help y
    :help copy-move
    :help usr_04.txt

G is another motion command.  It moves the cursor to the last line
in the file.  When prefixed by a number, it moves the cursor to that
line number.  See

    :help G

The characters

    +GP

tell Vim to move the cursor down one line, then to move the cursor
to the last line of the file, then to put the contents of the
unnamed register above the current line.  See

    :help quotequote
    :help P

Regards,
Gary

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Wierdness in vim

a joeiam
In reply to this post by Tim Chase
Thank you for your response!!!

On Thu, Mar 16, 2017 at 10:14 AM, Tim Chase <[hidden email]> wrote:

> On 2017-03-16 05:05, a joeiam wrote:
>> Issue:working in a file with about 6800 lines I find an error. Need
>> to add two lines to one 'section'. Used +y to yank and then used
>> +GP to place. Was absolutely unable to place the lines. Instead the
>> 2 lines were place at the end of the document.
>
> It looks like you're trying to yank to the system clipboard.  For
> that, you want
>
>   "+y
>
> (i.e., include the double-quote before hand).  The yanking sequence
> as you describe it currently goes to the beginning of the next line
>
>   :help +
>
> and then begins a yank, but leaves you in operator-pending mode as
> it's expecting a motion to specify where you want to yank to.
>
> If you've recently changed your vim, make sure that you're using one
> that has been built with clipboard support.  To do that, issue
>
>   :version
>
> and look for "+clipboard" instead of "-clipboard".  If you have
> "-clipboard", you're likely running what some distros call "vim-tiny"
> or an alternate vi such as nvi, stevie, or elvis.
>
> If you're really trying to yank two lines into the unnamed register,
> you need to specify the motion after the "y" by doing
>
>   y+
>
> which can also be written as
>
>   yj
>
> or
>
>   2Y
>
> Likewise, when you go to paste, your "+GP" translates as
>
>   +    Go to the beginning of the next line
>   G    Wait, actually go to the bottom of the file
>   P    Paste the most recently-yanked thing before the cursor
>
> If you want to paste from the system clipboard, again, you need to
> prefix the register reference with the double-quote:
>
>   "+GP
>
> That all said, unless you actually need the yank put on the system
> clipboard, vim has a bunch of named registers if you want to keep the
> content around, and defaults to the "unnamed" register.  So you may
> be good with just doing
>
>   yy
>
> to yank the row (or "y+" to yank two rows, or "yap" to yank the
> blank-line-delimited block), move to your destination, and
>
>   p
>
> to paste the content.  Note that those are all lowercase.  There is a
> "gp" command, but the (capital) "G" you're issuing is what moves you
> to the end of your file.
>
Trying to find the cheat sheet where I found the +GP command for pasting.
Of course cannot find it now! Have been using "The Vim Reference and Tut-
orial" as a primary reference and its not in that one.

I haven't tried using your suggested command sequence yet but I'm wondering
- - - been using V for line based select and then scrolling to the end of the
needed lines (anywhere from the one line to about 10) and then doing the +y.

The suggesting in ledger-cli was that emacs (or vim) would reduce keystrokes
and moving fromt he keyboard to the mouse and back again like when using
ctrl-c (etc). With adding even more keystrokes I'm wondering about that
efficiency - - - I just don't see it. (Not trying to complain I'm just
looking for
a quick entry system that is easy to edit that works well with ledger-cli
(wanting to add some in-line programs to make things even easier and that
AIUI is where vim and emacs shine) but its looking like one needs to be
real familiar with either vim or emacs BEFORE this happens. I might decide to
learn all the twists and turns of one of these two but if I hire someone to do
the entry of information for me - - - well that just doesn't fly for any
'bookkeeper' types.

>> Used +GP a couple more times not understanding why the 2 lines were
>> not placed and then I looked at the doc.I had gone from 6814 lines
>> to 12 877 lines and all of the lines were the 2 yanked (with a
>> blank line before and after each iteration).
>
> I suspect something got omitted and you ended up yanking from your
> current location to the end of the file, and then pasting that
> content. If your cursor was at the beginning of the file to start,
> that would double the size of the file.

Sort of but it was only lines that had gotten yanked but there were about
2000 copies of those 3 lines!

Thank you again for your explanation!!!!

Regards

Dee

--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: Wierdness in vim

Tim Chase
On 2017-03-16 13:12, o1bigtenor wrote:
> Trying to find the cheat sheet where I found the +GP command for
> pasting. Of course cannot find it now!

Count your blessings.  If it mis-instructed you on the clipboard
copy/paste, it's not a very good cheat sheet ;-)

> I haven't tried using your suggested command sequence yet but I'm
> wondering
> - - - been using V for line based select and then scrolling to the
> end of the needed lines (anywhere from the one line to about 10)
> and then doing the +y.

These sorts of things are great for letting Vim do the hard work.

While I've prodded ledger-cli to see what it was about, it wasn't for
me.  But from what I recall, each transaction is in a blank-line
delimited block.  So I'd start with

  yap

to "yank a paragraph".  This works from anywhere inside the paragraph
you're in and puts it in the unnamed clipboard register.  You can
then use

  }

as a motion to get to the bottom of current block, and then

  p

to paste it after the block.

> The suggesting in ledger-cli was that emacs (or vim) would reduce
> keystrokes and moving fromt he keyboard to the mouse and back again
> like when using ctrl-c (etc). With adding even more keystrokes I'm
> wondering about that efficiency - - - I just don't see it. (Not
> trying to complain I'm just looking for a quick entry system that
> is easy to edit that works well with ledger-cli (wanting to add
> some in-line programs to make things even easier and that AIUI is
> where vim and emacs shine) but its looking like one needs to be
> real familiar with either vim or emacs BEFORE this happens.

Indeed, learning either editor (or both and see which fits your brain
better) is likely a prerequisite for the speed-ups they hint at.  If
you do it frequently, you could map hot-keys/macros to do most of the
work.  It does look like there's a vim+ledger plugin that automates a
large bit of the work:

  https://github.com/ledger/vim-ledger

> I might decide to learn all the twists and turns of one of these
> two but if I hire someone to do the entry of information for me - -
> - well that just doesn't fly for any 'bookkeeper' types.

I'm not sure how well most "bookkeeper" types work with ledger-cli
regardless of which text editor you use to manage the file.  If they
do, I imagine that they would know how to deal with the text file in
their favorite editor, regardless of your local configuration.

> >> Used +GP a couple more times not understanding why the 2 lines
> >> were not placed and then I looked at the doc.I had gone from
> >> 6814 lines to 12 877 lines and all of the lines were the 2
> >> yanked (with a blank line before and after each iteration).
> >
> > I suspect something got omitted and you ended up yanking from your
> > current location to the end of the file, and then pasting that
> > content. If your cursor was at the beginning of the file to start,
> > that would double the size of the file.
>
> Sort of but it was only lines that had gotten yanked but there were
> about 2000 copies of those 3 lines!

It's possible you did something like

   2000p

which would paste 2000 copies.  Or, if you'd just pasted and that
you're working with financial numbers, typing a financial amount such
as

  2000.10

in normal-mode would be treated as a count (2000) followed by a
period which is Vi's "do the last thing I did".  The "10" would then
get treated as a count to the next command you issued.

-tim





--
--
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

---
You received this message because you are subscribed to the Google Groups "vim_use" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.