JumpToLastOccurrence : f{char} motions that count from the end of the line.
script karma |
Rating 12/6,
Downloaded by 2025 |
Comments, bugs, improvements
|
Vim wiki
|
created by |
Ingo Karkat |
|
script type |
utility |
|
description |
DESCRIPTION
The f{char}, F, t and T family of motions are often more effective
than the more general l, w and W motions. However, there are situations
where they are difficult to apply.
Take a long file system path like /var/opt/foo/a/very/long/path/to/filename.
Imagine you are on the beginning / and want to change the entire directory
path, but keep the filename. You'd either have to count occurrences (e.g. c8f/
or c2tf), do multiple moves ($T/cB), use visual mode (veeeeeeeelc), or a
search (c/filen<CR>).
This plugin extends the built-in f/F/t/T motions with counterparts that move
to the last occurrence of {char} in the line. For the above example, that
would be a short c,f/ to jump to the last slash in the line.
SEE ALSO
- The JumpToVerticalOccurrence.vim plugin (vimscript #4841) implements
variations of f / F that move vertically across lines, restricted to the
same screen column as the cursor.
USAGE
,f{char} To [count]'th occurrence of {char}, counting from the
end of the line. The cursor is placed on {char}
inclusive.
,F{char} To the [count]'th occurrence of {char}, counting from
the beginning of the line. The cursor is placed on
{char} exclusive.
,t{char} Till before [count]'th occurrence of {char}, counting
from the end of the line. The cursor is placed on the
character left of {char} inclusive.
,T{char} Till after [count]'th occurrence of {char}, counting
from the beginning of the line. The cursor is placed
on the character right of {char} exclusive.
All motions can be repeated with ; and ,. However,
the ,t and ,T motions will jump to, not until, the
next {char}. |
|
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 JumpToLastOccurrence*.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.016 or
higher.
- repeat.vim (vimscript #2136) plugin, version 1.1 or higher (optional)
CONFIGURATION
For a permanent configuration, put the following commands into your vimrc:
By default, all mappings start with , (comma) as the map leader instead of
using <Leader>. I personally find the default <Leader> key too far off the
keyboard to be useful for custom motions (which also cannot be repeated via
the . (dot) command, so they should be very fast to type repeatedly), but
quite suitable for general, less frequently used custom mappings.
To avoid losing the (rarely used) , mapping (which repeats latest f, t, F or
T in opposite direction), you can remap it to ,,:
nnoremap ,, ,
xnoremap ,, ,
onoremap ,, ,
If you don't agree with this and want all motions to start with <Leader> (or
any other key), you can do this (before sourcing the script):
let g:JumpToLastOccurrence_Leader = '<Leader>'
If you want to use completely different or only a few of the mappings, map
your keys to the <Plug>JumpToLastOccurrence_? mapping targets _before_
sourcing the script (e.g. in your vimrc). |
|
script versions (upload new version)
Click on the package to download.
ip used for rating: 18.97.9.175
|