(minor cleanup) |
(Change to TipImported template + severe manual clean) |
||
Line 1: | Line 1: | ||
{{review}} |
{{review}} |
||
+ | {{TipImported |
||
− | {{Tip |
||
|id=1014 |
|id=1014 |
||
+ | |previous=1013 |
||
− | |title=Visual selection of indent block |
||
+ | |next=1015 |
||
− | |created=October 8, 2005 |
+ | |created=October 8, 2005 |
|complexity=basic |
|complexity=basic |
||
|author=Robert Schols |
|author=Robert Schols |
||
|version=5.7 |
|version=5.7 |
||
|rating=16/11 |
|rating=16/11 |
||
− | |text= |
||
}} |
}} |
||
⚫ | |||
− | |||
⚫ | |||
<pre> |
<pre> |
||
− | :exe "normal V" | let temp_var=indent(line(".")) | while indent(line(".")+1) >= temp_var | exe "normal j" | endwhile |
+ | :exe "normal V" | let temp_var=indent(line(".")) | while indent(line(".")+1) >= temp_var | exe "normal j" | endwhile |
</pre> |
</pre> |
||
==Comments== |
==Comments== |
||
⚫ | |||
− | This idea was immensely useful for me, thank you. |
||
⚫ | |||
+ | <pre> |
||
− | function! SelectIndent () |
+ | function! SelectIndent () |
− | let temp_var=indent(line(".")) |
||
− | + | let temp_var=indent(line(".")) |
|
⚫ | |||
⚫ | |||
+ | exe "normal k" |
||
− | endwhile |
||
+ | endwhile |
||
⚫ | |||
⚫ | |||
⚫ | |||
+ | while indent(line(".")+1) >= temp_var |
||
− | + | exe "normal j" |
|
− | endwhile |
||
+ | endwhile |
||
− | endfun |
+ | endfun |
nmap <space> :call SelectIndent()<cr> |
nmap <space> :call SelectIndent()<cr> |
||
+ | </pre> |
||
− | spaceman--AT--foo.at |
||
− | , October 9, 2005 4:24 |
||
---- |
---- |
||
− | Actually it should be "normal k" and not "normal h". |
||
− | |||
− | h is left but k is up. |
||
− | |||
− | '''Anonymous''' |
||
− | , October 16, 2005 1:45 |
||
− | ---- |
||
− | Interesting; I might try it. |
||
Currently, I just set foldmethod=indent and select the folded area. |
Currently, I just set foldmethod=indent and select the folded area. |
||
− | Eric |
||
− | , October 27, 2005 12:10 |
||
− | ---- |
||
− | you made python bearable for an old lady like me. |
||
− | bless you son. |
||
− | |||
− | Jackie |
||
− | , June 24, 2006 22:52 |
||
---- |
---- |
||
− | <!-- parsed by vimtips.py in 0.852093 seconds--> |
Revision as of 03:34, 16 December 2007
Tip 1014 Printable Monobook Previous Next
created October 8, 2005 · complexity basic · author Robert Schols · version 5.7
This command will make a visual selection of the lines that have the same indent level or more as the current line.
:exe "normal V" | let temp_var=indent(line(".")) | while indent(line(".")+1) >= temp_var | exe "normal j" | endwhile
Comments
A slight modification, to select the area above the cursor position as well, and the whole thing wrapped in a function (and nmapped to <Space>):
function! SelectIndent () let temp_var=indent(line(".")) while indent(line(".")-1) >= temp_var exe "normal k" endwhile exe "normal V" while indent(line(".")+1) >= temp_var exe "normal j" endwhile endfun nmap <space> :call SelectIndent()<cr>
Currently, I just set foldmethod=indent and select the folded area.