michaeljsmith / vim-indent-object

Vim plugin that defines a new text object representing lines of code at the same indent level. Useful for python/vim scripts, etc.
http://www.vim.org/scripts/script.php?script_id=3037
MIT License
735 stars 61 forks source link

make use of il to cover one more useful text blocks #8

Open pinggit opened 11 years ago

pinggit commented 11 years ago

hi Michael:

I've beening using vim-indent-object as an extra text-object to handle my indented text blocks http://www.vim.org/scripts/script.php?script_id=3037

it's extremely useful in a daily base, because most of my text files are indentation-based.

however, there is one common scenario that is not (and seems should be ) covered by it:

.task 5 do this and do that

.task 6

this is more urgent

 do this
 and do that

I know this is not a programming scenario , but I remember even in some script there is such a need to action on this kind of blocks. currently both of the above are not covered under the text object.

and currently il is just linked to ii:

"

iI (I)nner (I)ndentation level (no lines above/below). Note that the iI mapping is mostly included simply for completeness, it is effectively a synonym for ii. " so I think it's good to make il mapping to the blocks that I mentioned above? thanks! regards ping
michaeljsmith commented 11 years ago

Hi Ping,

It seems like Markdown has screwed up the indentation of your example, but it was clearer in your email.

I'm guessing that what you would like to happen is that when you do on the second block (ie .task 6) then it would select the entire .task 6 block?

Thanks, Michael

pinggit commented 11 years ago

hi Michael: weird that your email I didn't notice..sorry.

.other tasks

  do this
  do that

.task 5 do this and do that .task 6

this is more urgent

  do this::
  #this has to be done!
       go to costco and buy ...
       better before friday
  and do that::
       go to canada

so my personally usage expreriences, there are 2 things might be worth to consider here:

1) current indentation block + 1 LINE up this is non-greedy, you only refer your current indented texts plus one line up, which , usually is a one line title or statement about what the task is about. I guess this is a very handy for most cases.

the drawback is, what if you actually want to delete 2 lines ahead of
current indented texts?

2) current indented block + one less indentation level up this is a bit greedy, you refer to current indented texts, plus whatever "above" them, that falls into the same upper level.

so putting your cursor at "go to costco" under task 6 and press dil 

, will delete the 1st sub-task (do this::), which has 2 lines title, but leave other sub-task intact.

the drawback is, if you do the same when cursor is on "do
this::" line, pressing "dil" will delete the whole upper level,
which can be the whole doc..

ideally, maybe make it user configurable?

let indent-obj-il = 0(case2)
let indent-obj-il = 1(default, case 1)
let indent-obj-il = 2

just FYI. thanks for your great work again.

On 1/8/2013 6:48 PM, Michael Smith wrote:

Hi Ping,

It seems like Markdown has screwed up the indentation of your example, but it was clearer in your email.

I'm guessing that what you would like to happen is that when you do on the second block (ie .task 6) then it would select the entire .task 6 block?

Thanks, Michael

— Reply to this email directly or view it on GitHub.