Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

An improved ft command for Vim

branch: master
README
*ft_improved.txt* - Better f/t command for Vim

Author:  Christian Brabandt <cb@256bit.org>
Version: 0.8 Thu, 27 Mar 2014 23:22:01 +0100

Copyright: (c) 2009-2013 by Christian Brabandt
           The VIM LICENSE applies to improved_ft.vim and improved_ft.txt
           (see |copyright|) except use improved_ft instead of "Vim".
           NO WARRANTY, EXPRESS OR IMPLIED.  USE AT-YOUR-OWN-RISK.

==============================================================================
1. Contents                                                  *improvedft-ft*

        1.  Contents...................................: |improvedft-ft|
        2.  Manual.....................................: |improvedft-manual|
        2.1   Enable...................................: |improvedft-Enable|
        2.2   Disable..................................: |improvedft-Disable|
        2.3   Tips.....................................: |improvedft-Tips|
        2.3.1 Using the YankRing.......................: |improvedft-YankRing|
        2.3.2 Ignoring case............................: |improvedft-ignorecase|
        2.4   Bugs.....................................: |improvedft-Bugs|
        3.  Feedback...................................: |improvedft-feedback|
        4.  History....................................: |improvedft-history|

==============================================================================
2. Improved ft command Manual                              *improvedft-manual*

Functionality

This plugin tries to improve the existing behaviour of the |f|, |F|, |t| and
|T| command by letting them move the cursor not only inside the current line,
but move to whatever line, where the character is found. Also the |,| and |;|
command should just work as expected.

It does consider counts given and should work simply as a user would be
expecting.

It basically does that, by remapping the f,F,t and T command to issue a search
for the character that is entered and moving the cursor there.


2.1 Enable                                               *improvedft-Enable*
----------

By default the new f,F,t,T commands should simply work. If you have disabled
the plugin (see |improvedft-Disable|), use the command >
    :EnableImprovedFT
<

2.2 Disable                                             *improvedft-Disable*
-----------

If for any reason, you want to disable the plugin, use >
    :DisableImprovedFT
<

2.3 Tips                                                  *improvedft-Tips*
--------
                                                        *improvedft-YankRing*

2.3.1 YankRing and the improved ft plugin
------------------------------------------

Both plugins map the ',', ';', 'f', 'F', 't' and 'T' key, so they don't work
together very well. The improved ft plugin tries to work around that by
setting a YankRing option that prevents mapping those keys and reloading the
YankRing plugin.

The following YankRing variables are set by the improved ft plugin: >

        let g:yankring_zap_keys = "/ ?"
        let g:yankring_o_keys  = 'b B w W e E d h j k l H M L y G ^ 0 $'
        let g:yankring_o_keys .= ' g_  g^ gm g$ gk gj gg ge gE - + _ '
        let g:yankring_o_keys .= ' iw iW aw aW as is ap ip a] a[ i] i['
        let g:yankring_o_keys .= ' a) a( ab i) i( ib a> a< i> i< at it'
        let g:yankring_o_keys .= ' a} a{ aB i} i{ iB a" a'' a` i" i'' i`'
<

If those variables have been customized in your .vimrc, the plugin detects it
and removes the ',', ';', 'f', 'F', 't' and 'T' from them.

The drawback of doing this is, that the YankRing possibly doesn't immediately
catch up in the YankRing itself and possibly will not be caught at all.

                                                    *improvedft-ignorecase*
2.3.2 Ignoring case when searching
----------------------------------

ft_improved tries to mimic the existing behaviour of the |f| |F| |t| |T| |,| |;|
commands as closely as possible. However, you might wish to search for the
character while ignoring case, so that fT will also jump to either the next
't' or 'T' character, whichever appears first.

To enable this, simply set this variable in your |.vimrc| >

    :let g:ft_improved_ignorecase = 1
<

To disable either |unlet| that variable, or set it to zero.

                                                    *improvedft-multichars*
2.3.3 Searching for more characters
-----------------------------------

ft_improved tries to mimic the existing behaviour of the |f| |F| |t| |T| |,| |;|
commands as closely as possible. However, you might wish to search for more
character to better find your position and not only allow one single char with
it.

To enable this, simply set this variable in your |.vimrc| >

    :let g:ft_improved_multichars = 1
<
As you type, the matching positions will be highlighted.

To disable either |unlet| that variable, or set it to zero.

If you have enabled it this way, you need to press enter, after having entered
the characters to search for, so that the plugin knows, when not to wait for more
characters and to start searching. Alternatively, if the entered characters
precisely only match one position in the current screen (excluding folds), it
will simply drop you there.

Note: This is highly experimental and basically turns your |f| |F| |t| |T| |,|
|;| keys to use a literal search function.

2.4 Bugs                                             *improvedft-Bugs*
--------

- When using T as operator and the match is the last character of a previous
  line, the motion will become inclusive and you will incorrectly also change
  that character. (also when ',' or ';' are searching backwards) That seems to
  be a bug within Vim. See also |exclusive|

==============================================================================
3. Feedback                                         *improvedft-feedback*

Feedback is always welcome. If you like the plugin, please rate it at the
vim-page:
http://www.vim.org/scripts/script.php?script_id=3877

You can also follow the development of the plugin at github:
http://github.com/chrisbra/improvedft

Please don't hesitate to report any bugs to the maintainer, mentioned in the
third line of this document.

==============================================================================
4. History                                              *improvedft-history*

0.8: Mar 27, 2014 "{{{1
- handle keys like <Enter>, <Tab> literally
- escape '/' correctly for |t| commands.

0.7: Aug 14, 2013 "{{{1
- small bugfixes
- correctly handle ignorecase setting |improvedft-ignorecase|
- escape '
- make ; work correctly when using backwards motion.

0.6: Mar 16, 2013 "{{{1
- |improvedft-multichars|
- save and restore search-history in all modes correctly

0.5: Feb 16, 2013 "{{{1
- ignorecase when searching, when g:ft_improved_ignorecase is set

0.4: Sep 09, 2012 "{{{1
- special handling of pattern / and ?

0.3: Aug 20, 2012 "{{{1
- fix issue https://github.com/chrisbra/improvedft/issues/1
  by disallowing the Yankring to map the keys f F t and T
- Better mapping of ';' key (patch by Marcin Szamotulski, thanks!)

0.2: Jan 13, 2012 {{{1
- disable debug mode
- enable |GLVS|

0.1: Jan 12, 2012 {{{1

- Initial upload
- development versions are available at the github repository
- put plugin on a public repository (http://github.com/chrisbra/improvedft)
  }}}

==============================================================================
Modeline:
vim:tw=78:ts=8:ft=help:et:fdm=marker:fdl=0:norl
Something went wrong with that request. Please try again.