Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
An improved ft command for Vim
VimL Makefile
branch: master

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
autoload
doc
plugin
.gitignore
Makefile
README
ft_improved.vmb

README

*ft_improved.txt* - Better f/t command for Vim

Author:  Christian Brabandt <cb@256bit.org>
Version: 0.9 Thu, 15 Jan 2015 21:40:10 +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.3.3 Searching for more chars.................: |improvedft-multichars|
        2.3.4 Consistent ,/; keys......................: |improvedft-consistent_comma|
        2.4   Mapping..................................: |improvedft-Mapping|
        2.5   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.
(Set g:ft_improved_nohighlight = 1 if you don't want the highlighting).

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.

                                                    *improvedft-consistent_comma*
2.3.4 Consistent ,/; keys
-------------------------
By default, the |,| will always search into the opposite direction of your
last |f|/|F|/|t|/|T| command, while the ';' will always search in the same
direciton.

If you rather like to have that the |;| will always search forward and the |,|
always backwards you can set the variable g:ft_improved_consistent_comma
variable like this in your |.vimrc| >

    :let g:ft_improved_consistent_comma = 1

2.4 Mapping                                             *improvedft-Mapping*
-----------
By default the keys |f| |F| |t| |T| |;| and |,| are mapped to a function that
performs the work. If for one reason, you do not want any of those keys to be
remapped, simply set the variable g:ft_improved_nomap_<key> to one where <key>
corresponds to any of the above keys (but use "comma" for "," and semicolon
for ";"). Say you do not want to have the ',' remapped, you would in your
|.vimrc| set: >

    :let g:ft_improved_nomap_comma = 1

2.5 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.9: Jan 15, 2015 "{{{
- do not mess up highlighting for |;| and |,| commands
- make count work correctly with multi-highlight match, so that only the
  count'th occurence gets highlighted.
- allow to disable mappings selectively |improvedft-Mapping|
  (issue https://github.com/chrisbra/improvedft/issues/4 reported by Maiko
  Cezar, thanks!)
- make the plugin not unneccessarily source the autoload script
- document |improvedft-consistent_comma|

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.