views:

80

answers:

3

I have some lines in a sass file:

.menu
  ul
    xx: xx
  li
    xx: xx
  a
    xx: xx
.others
  xx: xx

If I want to move the entire .menu part to right for a width of tab, I should use 7>>. It's so boring that I have to count there are how many lines in the .menu.

Is there any simple way to do this? I mean, to move a node and its children at the same time

A: 

Find the line numbers of the start and end lines (:set nu/set nonu), say 4 and 10, then use

:4,10s/^/\t/

That is, replace the start of the line with a tab character in the line range 4 through 10.

Or simply do the subtraction (end - start + 1) instead and use that for your repeat for >>, though obviously the cursor needs to be on the starting line for that. That's great for short segments, but if the segment is very long the other way is more convenient.

tvanfosson
you mean `:4,10s/^/\t/`
Amir Rachum
@Amir - you're right.
tvanfosson
@tvanfosson, I learnt a new skill from you, thank you!
Freewind
+3  A: 

Go to the first line of the node, press Shift-V, go to the last line of the node, press >.

Bolo
This is what I do.
Will Vousden
@Bolo, thanks, it's simple and useful
Freewind
+3  A: 

I suggest to select the "node" with its children and then indent it using > (or <).

To select indented text (which a "node" in a SASS-file is) in one keystroke use vim-indent-object plugin. This plugin defines additional text objects based on indentation level, which are selectable by vai, vii, etc. (just like, for example, words—vaw, viw, etc.). See additional details on the plugin's home page.

ib
@ib, thanks~ This is really helpful!
Freewind