From 9f8c26be23e2335e20f7198a4c9d29bd24ed918f Mon Sep 17 00:00:00 2001 From: Kevin Le Date: Mon, 23 Nov 2015 13:12:47 -0800 Subject: don't take over keys by default, require configuration in vimrc fixes #26 --- README.rst | 80 ++++++++++++++++++++++++++------------------------------------ 1 file changed, 34 insertions(+), 46 deletions(-) (limited to 'README.rst') diff --git a/README.rst b/README.rst index 6b59931..bb86391 100644 --- a/README.rst +++ b/README.rst @@ -13,25 +13,47 @@ for identifiers. The best way to navigate inside those identifiers using Vim built-in motions is the [count]f{char} motion, i.e. f{uppercase-char} or f\_, respectively. But we can make this easier: -This script defines motions 'w', 'b' and 'e' (similar -to 'w', 'b', 'e'), which do not move word-wise (forward/backward), but -Camel-wise; i.e. to word boundaries and uppercase letters. The motions also -work on underscore notation, where words are delimited by underscore ('_') -characters. From here on, both CamelCase and underscore_notation entities are -referred to as "words" (in double quotes). Just like with the regular motions, -a [count] can be prepended to move over multiple "words" at once. Outside of -"words" (e.g. in non-keyword characters like // or ;), the new motions move -just like the regular motions. +This script defines motions similar to 'w', 'b', 'e' which do not move +word-wise (forward/backward), but Camel-wise; i.e. to word boundaries and +uppercase letters. The motions also work on underscore notation, where words +are delimited by underscore ('_') characters. From here on, both CamelCase +and underscore_notation entities are referred to as "words" (in double quotes). +Just like with the regular motions, a [count] can be prepended to move over +multiple "words" at once. Outside of "words" (e.g. in non-keyword characters +like // or ;), the new motions move just like the regular motions. Vim provides a built-in 'iw' text object called 'inner word', which works in operator-pending and visual mode. Analog to that, this script defines inner -"word" motions 'iw', 'ib' and 'ie', which select the -"word" (or multiple "words" if a [count] is given) where the cursor is located. +"word" motions which select the "word" (or multiple "words" if a [count] is +given) where the cursor is located. Usage ====== +To use the default mappings, add the following to your vimrc:: + camelcasemotion#CreateMotionMappings('') -The new motions are 'w', 'b' and 'e', all of which can +If you want to use different mappings, map your keys to the +CamelCaseMotion_? mapping targets your vimrc). + +EXAMPLE: Map to w, b and e mappings:: + map w CamelCaseMotion_w + map b CamelCaseMotion_b + map e CamelCaseMotion_e + map ge CamelCaseMotion_ge + sunmap w + sunmap b + sunmap e + sunmap ge + +EXAMPLE: Map iw, ib and ie motions:: + omap iw CamelCaseMotion_iw + xmap iw CamelCaseMotion_iw + omap ib CamelCaseMotion_ib + xmap ib CamelCaseMotion_ib + omap ie CamelCaseMotion_ie + xmap ie CamelCaseMotion_ie + +Most commonly motions are 'w', 'b' and 'e', all of which can be used in normal mode, operator-pending mode (cp. :help operator), and visual mode. For example, type 'bcw' to change 'Camel' in 'CamelCase' to something else. @@ -109,37 +131,3 @@ To uninstall, use the ``:RmVimball`` command. **Dependencies** Requires Vim 7.0 or higher. - -**Configuration** - -If you want to use different mappings, map your keys to the -``CamelCaseMotion_?`` mapping targets _before_ sourcing this script (e.g. in -your .vimrc). - -**Example**: Use 'W', 'B' and 'E':: - - map CamelCaseMotion_w - map CamelCaseMotion_b - map CamelCaseMotion_e - -**Example**: Replace the default 'w', 'b' and 'e' mappings instead of defining -additional mappings 'w', 'b' and 'e':: - - map w CamelCaseMotion_w - map b CamelCaseMotion_b - map e CamelCaseMotion_e - map ge CamelCaseMotion_e - sunmap w - sunmap b - sunmap e - sunmap ge - -**Example**: Replace default 'iw' text-object and define 'ib' and 'ie' -motions:: - - omap iw CamelCaseMotion_iw - xmap iw CamelCaseMotion_iw - omap ib CamelCaseMotion_ib - xmap ib CamelCaseMotion_ib - omap ie CamelCaseMotion_ie - xmap ie CamelCaseMotion_ie -- cgit v1.1