All Projects → svermeulen → vim-NotableFt

svermeulen / vim-NotableFt

Licence: other
No description, website, or topics provided.

Programming Languages

Vim Script
2826 projects

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
  • Changes the way t and T repeat to be consistent. If you start with t, then repeat with ;, then go back with ,, you'll be at the same place (which is not the case with normal vim)

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.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].