sponsor Vim development Vim logo Vim Book Ad

EnhancedJumps : Enhanced jump and change list navigation commands.

 script karma  Rating 28/12, Downloaded by 918    Comments, bugs, improvements  Vim wiki

created by
Ingo Karkat
 
script type
utility
 
description
DESCRIPTION
This plugin enhances the built-in CTRL-I / CTRL-O jump commands:
- After a jump, the line, column and text of the next jump target are printed:
    next: 3,9 ENHANCED JUMPS    by Ingo Karkat
- An error message and the valid range for jumps in that direction is printed
  if a jump outside the jump list is attempted:
    Only 8 older jump positions.
- In case the next jump would move to another buffer, only a warning is
  printed at the first attempt:
    next: EnhancedJumps.vim
  The jump to another buffer is only done if the same jump command is repeated
  once more immediately afterwards; like this: Pressing CTRL-O, noticing the
  warning, then quickly pressing CTRL-O again to overcome the warning.
  With this, you can eagerly jump around the current buffer. Because you will
  be warned when a jump would move to another buffer, you're much less likely
  to get lost.

In addition to the enhanced jump commands, separate special mappings are
available that restrict the jump targets to only local locations (in the same
buffer) and remote locations (only in other buffers).


This plugin enhances the built-in g;/g, change list jump commands so that
they skip jumps to previous / later edit locations that lie within the
currently visible range. This makes it easier to navigate between distant
edits in a large buffer, without having to manually skip over all the local
changes.

RELATED WORKS
- back_to_recent_buffer.vim (vimscript #4290) implements going back to the
  previous buffer.

USAGE
Simply use the CTRL-O and CTRL-I commands to go to an older / newer cursor
position in the jump list. When a warning "next: {file}" is echoed, quickly
repeat the jump command to move to that buffer (a [count] need to not be
typed again; if you do include the [count], it must be the same as before).
If you do not want to move to that buffer, just ignore the warning, and
continue browsing the current buffer. On the next jump attempt, the warning
will be repeated.

g<CTRL-O>, g<CTRL-I>    Go to [count] older / newer cursor position in the
                        current buffer. Jumps to other buffers are not
                        considered. Useful when you mainly edited one file,
                        briefly jumped to another, and now want to recall
                        older positions without considering the other file.

<Leader><CTRL-O>, <Leader><CTRL-I>
                        Go to [count] older / newer cursor position in another
                        buffer. Jumps inside the current buffer are not
                        considered. Useful for recalling previously visited
                        buffers without going through all local positions.
                        Regardless of the jump direction, the last jump
                        position in a buffer is used when there are multiple
                        subsequent jumps in a buffer.

Simply use the g; and g, commands to go to an older / newer far change
position in the change list.

g;                      Go to [count] older far change (that lies outside the
                        currently visible range and is more than the current
                        window height lines away from the previous change or
                        the last accepted change).
                        If [count] is larger than the number of older far
                        change positions go to the oldest far change.
                        If there is no older far change, go to the [count]
                        older near change; i.e. fall back to the original
                        behavior.
                        If there is no older change an error message is given.
                        (not a motion command)
g,                      Go to [count] newer far change.
                        Just like g; but in the opposite direction.
 
install details
INSTALLATION
This script is packaged as a vimball. If you have the "gunzip" decompressor
in your PATH, simply edit the *.vmb.gz package in Vim; otherwise, decompress
the archive first, e.g. using WinZip. Inside Vim, install by sourcing the
vimball or via the :UseVimball command.
    vim EnhancedJumps*.vmb.gz
    :so %
To uninstall, use the :RmVimball command.

DEPENDENCIES
- Requires Vim 7.0 or higher.
- Requires the ingo-library.vim plugin (vimscript #4433), version 1.008 or
  higher.

CONFIGURATION
The time span in which the jump command must be repeated to overcome the
warning about jumping into another buffer defaults to (roughly) two seconds.
To change the timeout, set a different value (in milliseconds):
    let g:stopFirstAndNotifyTimeoutLen = 2000

If you do not want to override the built-in jump commands and use separate
mappings, or change the special additional mappings, map your keys to the
<Plug>... mapping targets _before_ sourcing the script (e.g. in your vimrc).
    nmap {          <Plug>EnhancedJumpsOlder
    nmap }          <Plug>EnhancedJumpsNewer
    nmap g{         <Plug>EnhancedJumpsLocalOlder
    nmap g}         <Plug>EnhancedJumpsLocalNewer
    nmap <Leader>{  <Plug>EnhancedJumpsRemoteOlder
    nmap <Leader>}  <Plug>EnhancedJumpsRemoteNewer

For the change list jump commands, you can choose between two alternatives,
the default one that falls back to near changes when there are no far changes
    nmap z; <Plug>EnhancedJumpsFarFallbackChangeOlder
    nmap z, <Plug>EnhancedJumpsFarFallbackChangeNewer
and a pure "far jumps" variant:
    nmap z; <Plug>EnhancedJumpsFarChangeOlder
    nmap z, <Plug>EnhancedJumpsFarChangeNewer

To disable the special additional mappings:
    nmap <Plug>DisableEnhancedJumpsLocalOlder  <Plug>EnhancedJumpsLocalOlder
    nmap <Plug>DisableEnhancedJumpsLocalNewer  <Plug>EnhancedJumpsLocalNewer
    nmap <Plug>DisableEnhancedJumpsRemoteOlder <Plug>EnhancedJumpsRemoteOlder
    nmap <Plug>DisableEnhancedJumpsRemoteNewer <Plug>EnhancedJumpsRemoteNewer
 

rate this script Life Changing Helpful Unfulfilling 
script versions (upload new version)

Click on the package to download.

package script version date Vim version user release notes
EnhancedJumps-3.01.vmb.gz 3.01 2013-11-19 7.0 Ingo Karkat - Handle it when the :changes command sometimes outputs just the header without a following ">" marker by catching the plugin exception in EnhancedJumps#Changes#GetJumps() and returning an empty List instead. This will cause the callers to fall back on the default g; / g, commands, which will then report the "E664: changelist is empty" error.
- Add dependency to ingo-library (vimscript #4433). *** You need to separately install ingo-library (vimscript #4433) version 1.008 (or higher)! ***
EnhancedJumps.vba.gz 3.00 2012-02-10 7.0 Ingo Karkat Implement enhanced change list navigation commands g; / g, that skip jumps to previous / later edit locations that lie within the currently visible range.
EnhancedJumps.vba.gz 2.00 2012-02-10 7.0 Ingo Karkat - Implement "local jumps" and "remote jumps" special mappings.
- Restructure internal jump list representation to get rid of index arithmetic, duplicated checks for current index in, and enhance filter performance.
- Split off functions to separate autoload script to help speed up Vim startup.
EnhancedJumps.vba.gz 1.13 2010-07-29 7.0 Ingo Karkat BUG: Jump opened fold at current position when "No newer/older jump position"
error occurred.
EnhancedJumps.vba.gz 1.12 2009-07-17 7.0 Ingo Karkat BF: Trailing space after the command to open the folds accidentally moved cursor one position to the right of the jump target.
EnhancedJumps.vba.gz 1.11 2009-07-14 7.0 Ingo Karkat BF: A '^\)' in the jump text caused "E55: Unmatched \)"
EnhancedJumps.vba.gz 1.10 2009-07-06 7.0 Ingo Karkat - ENH: To overcome the next buffer warning, a previously given [count] need not be specified again. A jump command with a different [count] than last time now is treated as a separate jump command and thus doesn't overcome the next buffer warning.
- BF: Folds at the jump target must be explicitly opened.
EnhancedJumps.vba.gz 1.00 2009-07-01 7.0 Ingo Karkat Initial upload
ip used for rating: 184.73.87.85

If you have questions or remarks about this site, visit the vimonline development pages. Please use this site responsibly.
Questions about Vim should go to the maillist. Help Bram help Uganda.
   
SourceForge.net Logo