sponsor Vim development Vim logo Vim Book Ad

motpat.vim : create motion mappings defined by a pattern

 script karma  Rating 7/3, Downloaded by 903  Comments, bugs, improvements  Vim wiki

created by
Andy Wokula
script type
Create motion mappings defined by a pattern.
The resulting keys can be used in Normal, Visual and Operator-pending mode; and they accept a count.

2017 Nov 10 https://github.com/Houl/motpat-vim


motpat#Map({buf-local}, {lhs-forw}, {lhs-back}, {rhs-pat}[, {excl}])

    {buf-local} if non-zero, create buffer-local mappings, else global mappings
    {lhs-forw} key to be mapped for forward searching (not if empty)
    {lhs-back} key to be mapped for backward searching (not if empty)
    {rhs-pat} pattern to define the motion, will be part of the resulting {rhs} of the mapping
    {excl} type of motion, one of "e" (default), "i" or "l", for exclusive, inclusive or linewise, makes use of |o_v|.

" the following two functions just omit one argument:
motpat#Fmap({buf-local}, {lhs-forw}, {rhs-pat}[, {excl}])
motpat#Bmap({buf-local}, {lhs-back}, {rhs-pat}[, {excl}])


ftplugin/vim.vim >
" simpler definition of ]], [[, ][, [], [" and ]"

" Move around functions.
call motpat#Map(1, ']]', '[[', '^\s*fu\%[nction]\>')
call motpat#Map(1, '][', '[]', '^\s*endf\%[unction]\>', 'l')

" Move around comments
call motpat#Fmap(1, ']"', '\%(^\s*".*\n\)\%(^\s*"\)\@!', 'l')
call motpat#Bmap(1, '["', '\%(^\s*".*\n\)\@<!\%(^\s*"\)', 'l')
install details
extract to a runtimepath folder

files in the archive:
autoload/gvmap.vim (helper script)

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
motpat_0.1.zip 0.1 2010-03-28 7.2 Andy Wokula Initial upload
ip used for rating:

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.
Vim at Github