Jumps: ctrl-o and ctrl-i

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

Jumps: ctrl-o and ctrl-i

Stefan Karlsson-3
I have just tried to get a hang of jumps (ctrl-o and ctrl-i) wich seems
to be a very neat feature of Vim.

However, when I use ctrl-o the cursor doesn't jump to the place where it
was before. I tested it on a file with four lines by starting with the
cursor on line 1, then issued a 2G, then 3G, and 4G.

So, when the cursor was on line 4 I hit ctrl-o. I'd expected the cursor
to go to line 3 but it went to line 1. It stayed there for a couple of
ctrl-o presses and then went back to line 4.

Neither ctrl-o nor ctrl-i are n-mapped to anything so I don't understand
what's wrong here. Or have I misunderstood the whole business of jumps?

-- Stefan
Reply | Threaded
Open this post in threaded view
|

Re: Jumps: ctrl-o and ctrl-i

Tim Chase-2
> However, when I use ctrl-o the cursor doesn't jump to the
> place where it was before. I tested it on a file with four
> lines by starting with the cursor on line 1, then issued a 2G,
> then 3G, and 4G.
>
> So, when the cursor was on line 4 I hit ctrl-o. I'd expected
> the cursor to go to line 3 but it went to line 1. It stayed
> there for a couple of ctrl-o presses and then went back to
> line 4.
>
> Neither ctrl-o nor ctrl-i are n-mapped to anything so I don't
> understand what's wrong here. Or have I misunderstood the
> whole business of jumps?


Strange that you're not getting the same behavior I'm getting
with my versions of Vim here.  I get the expected behavior you
described.

        bash> seq 1 4 > x.txt
        bash> vim x.txt
        1G2G3G4G

At this point, I'm on line 4.  The first ^O takes me to line 3,
the 2nd takes me to line 2, and the 3rd takes me back to the top
line.  ^I moves forward in the jump list exactly as I'd expect it to.

You may want to make dead sure that vim's not loading any extra
goodies or munging with your mappings by starting it with

        vim -u NONE -U NONE x.txt

and see if the symptoms persist.  Additionally, if you move
around with "small" motions (as opposed to actual "jumps" which
make it into the jump list), those don't get tracked quite the
same way.  So if you

        1G2Gk3G4G

(note the "k" in there), the jump list will not land on line 2.

-tim




Reply | Threaded
Open this post in threaded view
|

Re: Jumps: ctrl-o and ctrl-i

A.J.Mechelynck
In reply to this post by Stefan Karlsson-3
----- Original Message -----
From: "Stefan" <[hidden email]>
To: <[hidden email]>
Sent: Tuesday, July 26, 2005 11:11 PM
Subject: Jumps: ctrl-o and ctrl-i


>I have just tried to get a hang of jumps (ctrl-o and ctrl-i) wich seems to
>be a very neat feature of Vim.
>
> However, when I use ctrl-o the cursor doesn't jump to the place where it
> was before. I tested it on a file with four lines by starting with the
> cursor on line 1, then issued a 2G, then 3G, and 4G.
>
> So, when the cursor was on line 4 I hit ctrl-o. I'd expected the cursor to
> go to line 3 but it went to line 1. It stayed there for a couple of ctrl-o
> presses and then went back to line 4.
>
> Neither ctrl-o nor ctrl-i are n-mapped to anything so I don't understand
> what's wrong here. Or have I misunderstood the whole business of jumps?
>
> -- Stefan

I don't see that. (I tested it on a Vim helpfile, issuing G commands with
consecutive counts, even 1G 2G 3G 4G. Ctrl-O repeatedly went back to where I
came from: 4 to 3 to 2 to 1). You might try issuing the ":jumps" command at
varoius points in the process to display the jump table, or retry it after
loading Vim with -u NONE on the command-line to see if it makes a
difference.

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: Jumps: ctrl-o and ctrl-i

Stefan Karlsson-3
In reply to this post by Tim Chase-2
It seems that it is the jump list itself that is screwed up (not
ctrl-o), at least as far as I can see when doing a :jumps command. When
I try "vim -u NONE -U NONE test.txt"  as you suggested it works correct.
I still cant figure out what mapping or setteing causes this behavior
though.

Tim Chase wrote:

>> However, when I use ctrl-o the cursor doesn't jump to the
>> place where it was before. I tested it on a file with four
>> lines by starting with the cursor on line 1, then issued a 2G,
>> then 3G, and 4G.
>>
>> So, when the cursor was on line 4 I hit ctrl-o. I'd expected
>> the cursor to go to line 3 but it went to line 1. It stayed
>> there for a couple of ctrl-o presses and then went back to
>> line 4.
>>
>> Neither ctrl-o nor ctrl-i are n-mapped to anything so I don't
>> understand what's wrong here. Or have I misunderstood the
>> whole business of jumps?
>
>
>
> Strange that you're not getting the same behavior I'm getting with my
> versions of Vim here.  I get the expected behavior you described.
>
>     bash> seq 1 4 > x.txt
>     bash> vim x.txt
>     1G2G3G4G
>
> At this point, I'm on line 4.  The first ^O takes me to line 3, the
> 2nd takes me to line 2, and the 3rd takes me back to the top line.  ^I
> moves forward in the jump list exactly as I'd expect it to.
>
> You may want to make dead sure that vim's not loading any extra
> goodies or munging with your mappings by starting it with
>
>     vim -u NONE -U NONE x.txt
>
> and see if the symptoms persist.  Additionally, if you move around
> with "small" motions (as opposed to actual "jumps" which make it into
> the jump list), those don't get tracked quite the same way.  So if you
>
>     1G2Gk3G4G
>
> (note the "k" in there), the jump list will not land on line 2.
>
> -tim
>
>
>
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Jumps: ctrl-o and ctrl-i

A.J.Mechelynck
----- Original Message -----
From: "Stefan" <[hidden email]>
To: "Tim Chase" <[hidden email]>; <[hidden email]>
Sent: Tuesday, July 26, 2005 11:44 PM
Subject: Re: Jumps: ctrl-o and ctrl-i


> It seems that it is the jump list itself that is screwed up (not ctrl-o),
> at least as far as I can see when doing a :jumps command. When I try
> "vim -u NONE -U NONE test.txt"  as you suggested it works correct. I still
> cant figure out what mapping or setteing causes this behavior though.
[...]

You might try (without -u NONE -U NONE) hunting through the output of the
":scriptnames" command for a likely candidate. (You said Ctrl-O and Ctrl-I
weren't remapped -- does your vimrc [or something] remap the G key by any
chance?)

If nothing else avails, move or rename your scripts temporarily, then move
them back a few at a time, testing each time how the jump commands behave.
When you see a change in behaviour, you know that the culprit is in the few
ones you moved back latest.

You may want to print the output of ":scriptnames", as follows:

    :set nomore
    :redir @"
    :scriptnames
    :redir END
    :new
    :put
    :hardcopy!
    :q!

(This assumes that you have a printer and that your 'printoptions' are set
correctly. After that, you may want to ":set more" unless it's time for you
to ":qa".)

Best regards,
Tony.


Reply | Threaded
Open this post in threaded view
|

Re: Jumps: ctrl-o and ctrl-i

Bill McCarthy
In reply to this post by Tim Chase-2
On Tue 26-Jul-05 4:27pm -0500, Tim Chase wrote:

>         vim -u NONE -U NONE x.txt

Not to single out Tim, I have seen this set of options many
times here.

Is -U even meaningful for vim?

Also, -U NONE adds nothing when -u NONE us present.

Finally, if one is testing vim features, compatibility
should not be set (as it is above).

To use vim defaults with either vim or gvim, use

    -Nu NONE

--
Best regards,
Bill


Reply | Threaded
Open this post in threaded view
|

Re: Jumps: ctrl-o and ctrl-i

Tim Chase-2
>> vim -u NONE -U NONE x.txt
>
> Is -U even meaningful for vim?
>
> Also, -U NONE adds nothing when -u NONE us present.

possibly not for non-"g"vim, but, IIUC, if you're using gvim, you
can use "-u NONE" without specifying "-U NONE" and have your
gvimrc sourced, but not your vimrc.  I haven't read the source,
so those who have can claim much more authority on the matter :)

I picked up the habit of using both when someone (perhaps even
Bram himself) suggested it for troubleshooting a problem.

> Finally, if one is testing vim features, compatibility should
> not be set (as it is above).

This is a good observation and one I often forget to take into
account...good catch :)

> To use vim defaults with either vim or gvim, use
>
> -Nu NONE

I'll likely continue to use both the -u and -U versions together
out of habit...sorta a "belt-and-suspenders" sorta thing; but I
will try to make note in the future that if it may end up being a
compatibility issue, one may have to use -N as well.

Thanks for catching that.

-tim




Reply | Threaded
Open this post in threaded view
|

Re: Jumps: ctrl-o and ctrl-i

Bill McCarthy
On Wed 27-Jul-05 6:12am -0500, Tim Chase wrote:

>>> vim -u NONE -U NONE x.txt

>> Is -U even meaningful for vim?
>>
>> Also, -U NONE adds nothing when -u NONE us present.

> possibly not for non-"g"vim, but, IIUC, if you're using gvim, you
> can use "-u NONE" without specifying "-U NONE" and have your
> gvimrc sourced, but not your vimrc.  I haven't read the source,
> so those who have can claim much more authority on the matter :)

There's no need to read the start up code source, Tim, it is
quite clear in the help file (see `:h -u` second paragraph
second sentence).  Reading on, you will see that -u NORC
does the same wrt gvimrc.

If you are still unconvinced, add to the top of your gvimrc
a line such as:

    let g:mygs = "gvimrc was sourced"

Then you can try `:echo mygs` after startup.

BTW, the behavior can be overridden my explicitly requesting
your gvimrc be used:

    gvim -Nu NONE -U /vim/_gvimrc
    gvim -Nu NORC -U /vim/_gvimrc

While you are testing, try out:

    vim -Nu NONE -U /vim/_gvimrc

to see that -U is ignored for non-GUI even with used
explicitly.

--
Best regards,
Bill


Reply | Threaded
Open this post in threaded view
|

Re: Jumps: ctrl-o and ctrl-i: The problem was "showpairs.vim"

Stefan Karlsson-3
In reply to this post by A.J.Mechelynck
The culprit was a plugin called "showpairs.vim". Strange that nobody (?)
else has noticed this ... Anyway, after removing it jumping around works
as expected.

Thanks for your help!


-- Stefan



Tony Mechelynck wrote:

> ----- Original Message ----- From: "Stefan" <[hidden email]>
> To: "Tim Chase" <[hidden email]>; <[hidden email]>
> Sent: Tuesday, July 26, 2005 11:44 PM
> Subject: Re: Jumps: ctrl-o and ctrl-i
>
>
>> It seems that it is the jump list itself that is screwed up (not
>> ctrl-o), at least as far as I can see when doing a :jumps command.
>> When I try "vim -u NONE -U NONE test.txt"  as you suggested it works
>> correct. I still cant figure out what mapping or setteing causes this
>> behavior though.
>
> [...]
>
> You might try (without -u NONE -U NONE) hunting through the output of
> the ":scriptnames" command for a likely candidate. (You said Ctrl-O
> and Ctrl-I weren't remapped -- does your vimrc [or something] remap
> the G key by any chance?)
>
> If nothing else avails, move or rename your scripts temporarily, then
> move them back a few at a time, testing each time how the jump
> commands behave. When you see a change in behaviour, you know that the
> culprit is in the few ones you moved back latest.
>
> You may want to print the output of ":scriptnames", as follows:
>
>    :set nomore
>    :redir @"
>    :scriptnames
>    :redir END
>    :new
>    :put
>    :hardcopy!
>    :q!
>
> (This assumes that you have a printer and that your 'printoptions' are
> set correctly. After that, you may want to ":set more" unless it's
> time for you to ":qa".)
>
> Best regards,
> Tony.
>
>
Reply | Threaded
Open this post in threaded view
|

Re: Jumps: ctrl-o and ctrl-i

A.J.Mechelynck
In reply to this post by Tim Chase-2
----- Original Message -----
From: "Tim Chase" <[hidden email]>
To: "Bill McCarthy" <[hidden email]>
Cc: "Vim List" <[hidden email]>
Sent: Wednesday, July 27, 2005 1:12 PM
Subject: Re: Jumps: ctrl-o and ctrl-i


>>> vim -u NONE -U NONE x.txt
>>
>> Is -U even meaningful for vim?
>>
>> Also, -U NONE adds nothing when -u NONE us present.
>
> possibly not for non-"g"vim, but, IIUC, if you're using gvim, you
> can use "-u NONE" without specifying "-U NONE" and have your
> gvimrc sourced, but not your vimrc.  I haven't read the source,
> so those who have can claim much more authority on the matter :)
>
> I picked up the habit of using both when someone (perhaps even
> Bram himself) suggested it for troubleshooting a problem.
[...]

I think I too saw Bram using both; but it says under ":help -u" that -u NONE
will prevent both vimrc and gvimrc from loading, as well as the plugins.
After some research I notice in version5.txt two items:

(line 604):
New command-line arguments    *added-cmdline-args*
--------------------------

|-U|  Set the gvimrc file to be used.  Like "-u" for the vimrc.

(line 758):
- "vim -u NONE" now also stops loading the .gvimrc and other GUI inits.
|-u|
  Use "-U" to use another gvimrc file.  |-U|

Thus it seems to me that right from 5.0 "-u NONE" meant "neither vimrc nor
gvimrc" and that AFAICT using both -u NONE and -U NONE should never have
been necessary (since before then, -U didn't exist). I am puzzled.


Best regards,
Tony.