Hi,

I want 'header' text object (select with 'vah') to be extendable by
further `ah` presses like ordinary `vaw`, `aw` works.

So this is example data:
= Header 1 =
asdflkja
asdlfkj
asldfkj
lkasdjf

== Header 2 ==
asdfsad
asdfasdf
sdfasdfas
asdfa

= Header 1 =
asdfasdfk

This is my attempt:
function! Count_first_sym(line) "{{{
  let idx = 0
  while a:line[idx] == a:line[0] && idx < len(a:line)
    let idx += 1
  endwhile
  return idx
endfunction "}}}

function! TO_header() "{{{
  if !search('^\(=\+\)[^=]\+\1\s*$', 'bcW')
    return
  endif

  let level = Count_first_sym(getline(line('.')))

  normal V

  if search('^\(=\{1,'.level.'}\)[^=]\+\1\s*$', 'W')
    call cursor(line('.') - 1, 0)
  else
    call cursor(line('$'), 0)
  endif
endfunction

vmap ah :call TO_header()<CR>

It only selects a header and I don't know where to dig to make it
extendable to select further.

Any suggestions?

Thanks,
Maxim.
--~--~---------~--~----~------------~-------~--~----~
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php
-~----------~----~----~----~------~----~------~--~---

Reply via email to