Vim Tips Wiki
(Change to TipImported template + severe manual clean)
(Move categories to tip template)
Line 9: Line 9:
 
|version=5.7
 
|version=5.7
 
|rating=16/11
 
|rating=16/11
  +
|category1=
  +
|category2=
 
}}
 
}}
 
This command will make a visual selection of the lines that have the same indent level or more as the current line.
 
This command will make a visual selection of the lines that have the same indent level or more as the current line.

Revision as of 08:50, 25 April 2008

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.