Add text objects for list items

I put the function in lst.vim, not base.vim because it uses some
functions from lst.vim and because it's list stuff.
This commit is contained in:
EinfachToll 2013-10-30 10:53:34 +01:00
parent e9b1b66807
commit 140d32fcdd
3 changed files with 28 additions and 1 deletions

View File

@ -1410,6 +1410,24 @@ function! vimwiki#lst#setup_marker_infos() "{{{
endfunction "}}} endfunction "}}}
function! vimwiki#lst#TO_list_item(inner, visual) "{{{
let lnum = prevnonblank('.')
let item = s:get_corresponding_item(lnum)
if item.type == 0
return
endif
let from_line = item.lnum
if a:inner
let to_line = s:get_last_line_of_item(item)
else
let to_line = s:get_last_line_of_item_incl_children(item)
endif
normal! V
call cursor(to_line, 0)
normal! o
call cursor(from_line, 0)
endfunction "}}}
fun! vimwiki#lst#fold_level(lnum) "{{{ fun! vimwiki#lst#fold_level(lnum) "{{{
let cur_item = s:get_item(a:lnum) let cur_item = s:get_item(a:lnum)
if cur_item.type != 0 if cur_item.type != 0

View File

@ -471,6 +471,9 @@ i\ An inner cell in a table.
ac A column in a table. ac A column in a table.
ic An inner column in a table. ic An inner column in a table.
al A list item plus it's children.
il A single list item.
============================================================================== ==============================================================================
4. Commands *vimwiki-commands* 4. Commands *vimwiki-commands*
@ -814,7 +817,7 @@ You can nest and mix the various types: >
- Bulleted list item 3 - Bulleted list item 3
Note that a space after the list item markers (-, *, 1. etc.) are essential Note that a space after the list item markers (-, *, 1. etc.) is essential
List items can span multiple lines: > List items can span multiple lines: >
* Item 1 * Item 1

View File

@ -416,6 +416,12 @@ vnoremap <silent><buffer> ac :<C-U>call vimwiki#base#TO_table_col(0, 1)<CR>
onoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 0)<CR> onoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 0)<CR>
vnoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR> vnoremap <silent><buffer> ic :<C-U>call vimwiki#base#TO_table_col(1, 1)<CR>
onoremap <silent><buffer> al :<C-U>call vimwiki#lst#TO_list_item(0, 0)<CR>
vnoremap <silent><buffer> al :<C-U>call vimwiki#lst#TO_list_item(0, 1)<CR>
onoremap <silent><buffer> il :<C-U>call vimwiki#lst#TO_list_item(1, 0)<CR>
vnoremap <silent><buffer> il :<C-U>call vimwiki#lst#TO_list_item(1, 1)<CR>
if !hasmapto('<Plug>VimwikiAddHeaderLevel') if !hasmapto('<Plug>VimwikiAddHeaderLevel')
nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel
endif endif