2013-12-07 12:55:11 -05:00
|
|
|
*exchange.txt* Plugin to define a text exchange operator
|
|
|
|
|
|
|
|
Author: Tom McDonald <http://tommcdo.com>
|
|
|
|
License: Same terms as Vim itself (see |license|)
|
|
|
|
|
|
|
|
This plugin is only available if 'compatible' is not set.
|
|
|
|
|
|
|
|
INTRODUCTION *exchange*
|
|
|
|
|
|
|
|
This plugin provides |operators| for exchanging text in two places. The main
|
2014-04-27 10:21:27 -04:00
|
|
|
operator is |cx|, which is used in pairs. Each time it is used, it defines a
|
2014-06-24 10:27:10 -04:00
|
|
|
region of text to be exchanged; on the second use, the two defined regions are
|
|
|
|
exchanged. If one region is fully contained within the other, it replaces the
|
|
|
|
containing region.
|
2013-12-07 12:55:11 -05:00
|
|
|
|
|
|
|
MAPPINGS *exchange-mappings*
|
|
|
|
|
|
|
|
*cx* *exchange-define*
|
|
|
|
cx{motion} Used in pairs.
|
|
|
|
FIRST USE: define the first region of text to be
|
|
|
|
exchanged. Any valid {motion} can be used.
|
|
|
|
SECOND USE: define the second region of text and
|
|
|
|
perform the exchange.
|
|
|
|
Note: If a region was defined accidentally, it can
|
|
|
|
be cleared with |cxc|
|
|
|
|
|
2013-12-09 20:59:35 -05:00
|
|
|
*cxx* *exchange-define-line*
|
|
|
|
cxx Like |cx|, but for the current line. |linewise|
|
|
|
|
|
2013-12-07 12:55:11 -05:00
|
|
|
*cxc* *exchange-clear*
|
|
|
|
cxc Clear any defined region of text (previously defined
|
|
|
|
by a |cx| command)
|
|
|
|
|
2014-02-24 19:37:04 -05:00
|
|
|
*v_X* *exchange-visual*
|
2014-06-24 10:27:10 -04:00
|
|
|
{Visual}X Can be used in |visual-mode|.
|
2014-02-24 19:37:04 -05:00
|
|
|
|
2014-11-24 09:18:59 -05:00
|
|
|
COMMANDS *exchange-commands*
|
|
|
|
|
|
|
|
*exchange-:ExchangeClear*
|
|
|
|
:ExchangeClear Ex-command version of |cxc|.
|
|
|
|
|
2013-12-07 12:55:11 -05:00
|
|
|
EXAMPLES *exchange-examples*
|
|
|
|
|
|
|
|
In the text below, we will exchange everything inside the parentheses with
|
|
|
|
everything inside the double quotes.
|
|
|
|
|
|
|
|
Tom "a Vim plugin developer" McDonald (The Dev)
|
|
|
|
|
|
|
|
First, place your cursor somewhere inside the quoted string and type `cxi"`.
|
|
|
|
Then move your cursor to somewhere inside the parentheses and type `cxi)`. The
|
|
|
|
text will the be changed to:
|
|
|
|
|
|
|
|
Tom "The Dev" McDonald (a Vim plugin developer)
|
|
|
|
|
|
|
|
It should be noted that I don't actually go by that nickname.
|
|
|
|
|
2013-12-10 11:43:08 -05:00
|
|
|
SETTINGS *exchange-settings*
|
|
|
|
|
2013-12-21 23:00:46 -05:00
|
|
|
To change the default mappings, simply provide your own mappings to the
|
|
|
|
commands below. The default mappings are as follows:
|
2013-12-10 12:06:09 -05:00
|
|
|
|
2013-12-22 10:05:38 -05:00
|
|
|
nmap cx <Plug>(Exchange)
|
2014-06-30 15:57:27 -04:00
|
|
|
xmap X <Plug>(Exchange)
|
2013-12-22 10:05:38 -05:00
|
|
|
nmap cxc <Plug>(ExchangeClear)
|
|
|
|
nmap cxx <Plug>(ExchangeLine)
|
2013-12-10 11:43:08 -05:00
|
|
|
|
2013-12-21 23:00:46 -05:00
|
|
|
For example, to change the mapping for exchanging a line, use the following:
|
|
|
|
|
2013-12-22 10:05:38 -05:00
|
|
|
nmap cX <Plug>(ExchangeLine)
|
2013-12-21 23:00:46 -05:00
|
|
|
|
|
|
|
This will use the mapping `cX`, and the default `cxx` will not be mapped.
|
|
|
|
|
|
|
|
*g:exchange_no_mappings*
|
|
|
|
g:exchange_no_mappings ~
|
|
|
|
|
|
|
|
If this variable is defined, the default mappings will not be created.
|
|
|
|
|
2013-12-10 12:09:59 -05:00
|
|
|
ISSUES AND TODO *exchange-issues*
|
|
|
|
*exchange-todo*
|
2013-12-07 12:55:11 -05:00
|
|
|
|
|
|
|
See https://github.com/tommcdo/vim-exchange/issues for bugs and issues.
|
|
|
|
|
|
|
|
vim:tw=78:ts=8:ft=help:norl:
|