sponsor Vim development Vim logo Vim Book Ad

vim-NotableFt : Changes 'f' and 't' to only match notable characters

 script karma  Rating 0/0, Downloaded by 582  Comments, bugs, improvements  Vim wiki

created by
Steve Vermeulen
 
script type
utility
 
description
For the most up to date version see this github page:

https://github.com/svermeulen/vim-NotableFt

This plugin changes the behaviour of the `f`, `F`, `t`, `T`, `;` and `,` commands to only match on characters that are considered 'notable'. This includes:
- The 'humps' of camel case words
- The beginning and end of words
- Any non-word characters like `. , : ( !`

Note that these rules only apply when the given search character is lower case.  This is because while this behaviour is what you want almost all the time, sometimes you still want to be able to search for characters that are not 'notable'.  You can do this using upper case search.

For example, given this line:

`this is a test line`

With your cursor at the beginning, if you search `fi`, your cursor will move to the word 'is' (^ represents cursor)

`this ^s a test line`

Whereas, if you search `fI` instead, your cursor will move to:

`th^s is a test line`

This plugin also adds the following behaviour:
- Multiline - Can search across multiple lines or continue searching across multiple lines using `;` and `,` keys
- Highlighting - Highlights all matching characters on current line, previous matching line, and next matching line
- Allows repeating `t` and `T` commands using `;` or `,` commands

It's also worth noting that it only adds the new position to the jumplist if you've changed lines

###Search Direction###

By default, NotableFt will preserve Vim's behaviour of searching left-to-right with `;` after using `f`, and searching right-to-left with `;` when using `t`.  However, it also includes an alternative approach, which uses fixed directions for the `;` and `,` keys.  So if that's something you want to use instead, you can enable it by including the following in your .vimrc:

    let g:NotableFtUseFixedDirection = 1

In other words, when this option is enabled, the `;` key will always go left-to-right, and the `,` key will always go right-to-left.

###Key Customization###

If you have remapped any of the `f`/`F`/`t`/`T`/`;`/`,` keys you can still use the plugin without changing it, by including the following in your .vimrc:

`let g:NotableFtUseDefaults = 0`

With this set, NotableFT will not remap anything.  You can then remap whatever keys you want to the following `<plug>NotableFt` mappings:

    <plug>NotableFtRepeatSearchForward
    <plug>NotableFtRepeatSearchBackward
    <plug>NotableFtSearchFForward
    <plug>NotableFtSearchFBackward
    <plug>NotableFtSearchTForward
    <plug>NotableFtSearchTBackward

See the file `NotableFt.vim` for an example of how to map to these.

 
install details
 

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
vim-NotableFt-1.0.zip 1.0 2016-01-07 7.0 Steve Vermeulen Initial upload
ip used for rating: 3.238.95.208

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