*smartchr.txt* Insert several candidates with a single key
Version 0.1.1
Script ID: 2290
Copyright (C) 2008 kana <http://whileimautomaton.net/>
License: MIT license {{{
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be included
in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
}}}
CONTENTS *smartchr-contents*
Introduction |smartchr-introduction|
Interface |smartchr-interface|
Functions |smartchr-functions|
Bugs |smartchr-bugs|
Changelog |smartchr-changelog|
==============================================================================
INTRODUCTION *smartchr-introduction*
*smartchr* is a Vim plugin to support input several candidates with a single
key, like ess-smart-underscore in Emacs Speaks Statistics -- when user types
"_" key, it inserts " <- " for the first time or it replaces " <- " by "_" for
the second time. This plugin provides functions to support to define such
key bindings easily. For example:
>
<
Requirements:
- Vim 7.1 or later
Latest version:
http://github.com/kana/config/commits/vim-smartchar
Document in HTML format:
http://kana.github.com/config/vim/smartchr.html
==============================================================================
INTERFACE *smartchr-interface*
------------------------------------------------------------------------------
FUNCTIONS *smartchr-functions*
*smartchr#loop()*
smartchr#loop(s1, s2, ..., s{N}, [{context}])
Same as |smartchr#one_of()|, but it returns the key sequence to
replace s{N} by s1 for the {N+1}th time. For example,
>
<
With the above setting, whenever user types "_" key:
- " <- " is inserted for the 1st time, or
- the previously inserted " <- " is removed then "_" is inserted for
the 2nd time, or
- the previously inserted "_" is removed then " <- " is inserted for
the 3rd time, and so forth.
See |smartchr-context| for the details of {context}.
*smartchr#one_of()*
smartchr#one_of(s1, s2, ..., s{N}, [{context}])
Returns a string which represents the key sequence to insert one of
the given arguments. For example, the following setting emulates
ess-smart-underscore in Emacs Speaks Statistics:
>
<
With the above setting, whenever user types "_" key:
- " <- " is inserted for the 1st time, or
- the previously inserted " <- " is removed then "_" is inserted for
the 2nd time.
More generally, this function returns the key sequence to:
- insert s1 for the 1st time, or
- replace s1 by s2 for the 2nd time, or
- ...
- replace s{N-1} argument by s{N} for the {N}th time.
See |smartchr-context| for the details of {context}.
Context Designator *smartchr-context*
|smartchr-functions| takes an optional argument {context} which is
called "context designator". It is a dictionary to specify context to
enable the functions. It can contain one or more of the following
items:
"ctype" (optional)
A string which specifies types of Command-line mode. Each
character in this string must be a return value of
|getcmdtype()|.
In Command-line mode:
If the current type of Command-line mode is specified
in "ctype" value, the functions are enabled.
Otherwise they are disabled.
In other modes:
The functions are always enabled.
If this item is omitted, the functions are not disabled by the
current type of Command-line mode.
"fallback" (optional)
A string which is inserted if the functions are disabled.
If this item is omitted, s{N}, the {N}th argument given to the
functions is used instead.
Examples:
>
<
==============================================================================
BUGS *smartchr-bugs*
- Currently, there is no known issue.
==============================================================================
CHANGELOG *smartchr-changelog*
0.1.1 2010-02-21T19:20:29+09:00 *smartchr-changelog-0.1.1*
- Add |smartchr-context| to enable/disable |smartchr-functions| in
specified context.
Example configuration:
cnoremap <expr> ( smartchr#loop('\(', '(', {'ctype': '/?'})
0.1.0 2010-02-18T00:32:31+09:00 *smartchr-changelog-0.1.0*
- Support Command-line mode.
(Thanks to Tatsuhiro Ujihisa for reporting this)
Example configuration:
cnoremap <expr> \ smartchr#loop('~/', '\')
0.0.2 2010-02-17T22:11:42+09:00 *smartchr-changelog-0.0.2*
- Add tests.
0.0.1 2008-08-28T12:39:07+09:00 *smartchr-changelog-0.0.1*
- Add |smartchr#loop()|.
0.0.0 2008-07-11T11:55:47+09:00 *smartchr-changelog-0.0.0*
- Initial version.
==============================================================================
vim:tw=78:ts=8:ft=help:norl:fen:fdl=0:fdm=marker: