]>
Commit | Line | Data |
---|---|---|
0d23b6e5 BB |
1 | *indent-object.txt* Text objects based on indent levels.\r |
2 | \r | |
3 | Copyright (c) 2010 Michael Smith\r | |
4 | \r | |
5 | Indent Text Objects\r | |
6 | \r | |
7 | INTRODUCTION |idntobj-introduction|\r | |
8 | TEXT OBJECTS |idntobj-objects|\r | |
9 | BLANK LINES |idntobj-blanklines|\r | |
10 | ABOUT |idntobj-about|\r | |
11 | \r | |
12 | \r | |
13 | ==============================================================================\r | |
14 | INTRODUCTION *idntobj-introduction*\r | |
15 | \r | |
16 | Vim text objects provide a convenient way to select and operate on various\r | |
17 | types of objects. These objects include regions surrounded by various types of\r | |
18 | brackets and various parts of language (ie sentences, paragraphs, etc).\r | |
19 | \r | |
20 | This plugin defines a new text object, based on indentation levels. This is\r | |
21 | very useful in languages such as Python, in which the syntax defines scope in\r | |
22 | terms of indentation. Using the objects defined in this plugin, an entire if\r | |
23 | structure can be quickly selected, for example.\r | |
24 | \r | |
25 | \r | |
26 | ==============================================================================\r | |
27 | TEXT OBJECTS *ai* *ii* *aI* *iI* *idntobj-objects*\r | |
28 | \r | |
29 | This plugin defines two new text objects. These are very similar - they differ\r | |
30 | only in whether they include the line below the block or not.\r | |
31 | \r | |
32 | Key Mapping Description ~\r | |
33 | >\r | |
34 | <count>ai (A)n (I)ndentation level and line above.\r | |
35 | <count>ii (I)nner (I)ndentation level (no line above).\r | |
36 | <count>aI (A)n (I)ndentation level and lines above/below.\r | |
37 | <count>iI (I)nner (I)ndentation level (no lines above/below).\r | |
38 | <\r | |
39 | \r | |
40 | Note that the iI mapping is mostly included simply for completeness, it is\r | |
41 | effectively a synonym for ii.\r | |
42 | \r | |
43 | Just like regular text objects, these mappings can be used either with\r | |
44 | operators expecting a motion, such as 'd' or 'c', as well as in visual mode.\r | |
45 | In visual mode the mapping can be repeated, which has the effect of\r | |
46 | iteratively increasing the scope of indentation block selected. Specifying a\r | |
47 | count can be used to achieve the same effect.\r | |
48 | \r | |
49 | The difference between |ai| and |aI| is that |ai| includes the line\r | |
50 | immediately above the indentation block, whereas aI includes not only that,\r | |
51 | but also the line below. Which of these is most useful largely depends on the\r | |
52 | structure of the language being edited.\r | |
53 | \r | |
54 | For example, when editing the Python code, |ai| is generally more useful, as\r | |
55 | the line above the indentation block is usually related to it. For example, in\r | |
56 | the following code (* is used to indicate the cursor position):\r | |
57 | >\r | |
58 | if foo > 3:\r | |
59 | log("foo is big") *\r | |
60 | foo = 3\r | |
61 | do_something_else()\r | |
62 | <\r | |
63 | the if clause is logically related to the code block, whereas the function\r | |
64 | call below is not. It is unlikely we would want to select the line below when\r | |
65 | we are interested in the if block.\r | |
66 | \r | |
67 | However, in other languages, such as Vim scripts, control structures are\r | |
68 | usually terminated with something like 'endif'. Therefore, in this example:\r | |
69 | >\r | |
70 | if foo > 3\r | |
71 | echo "foo is big" *\r | |
72 | let foo = 3\r | |
73 | endif\r | |
74 | call do_something_else()\r | |
75 | <\r | |
76 | we would more likely want to include the endif when we select the if\r | |
77 | structure.\r | |
78 | \r | |
79 | \r | |
80 | ==============================================================================\r | |
81 | BLANK LINES *idntobj-blanklines*\r | |
82 | \r | |
83 | When scanning code blocks, the plugin usually ignores blank lines. There is an\r | |
84 | exception to this, however, when the block being selected is not indented. In\r | |
85 | this case if blank lines are ignored, then the entire file would be selected.\r | |
86 | Instead when code at the top level is being indented blank lines are\r | |
87 | considered to delimit the block.\r | |
88 | \r | |
89 | \r | |
90 | ==============================================================================\r | |
91 | ABOUT *idntobj-about*\r | |
92 | \r | |
93 | vim-indent-object was written by Michael Smith <msmith@msmith.id.au>. The\r | |
94 | project repository is kept at:\r | |
95 | \r | |
96 | http://github.com/michaeljsmith/vim-indent-object\r | |
97 | \r | |
98 | Any feedback or criticism is welcome, and can be mailed to the author at the\r | |
99 | above email address. Alternatively issues can be raised on the project\r | |
100 | website.\r | |
101 | \r | |
102 | Licence:\r | |
103 | \r | |
104 | Permission is hereby granted, free of charge, to any person obtaining a copy\r | |
105 | of this software and associated documentation files (the "Software"), to\r | |
106 | deal in the Software without restriction, including without limitation the\r | |
107 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\r | |
108 | sell copies of the Software, and to permit persons to whom the Software is\r | |
109 | furnished to do so, subject to the following conditions:\r | |
110 | \r | |
111 | The above copyright notice and this permission notice shall be included in\r | |
112 | all copies or substantial portions of the Software.\r | |
113 | \r | |
114 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\r | |
115 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\r | |
116 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\r | |
117 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\r | |
118 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\r | |
119 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS\r | |
120 | IN THE SOFTWARE.\r |