From 140d32fcddce8bbbfd069e529a947f7c3bbc3bf5 Mon Sep 17 00:00:00 2001 From: EinfachToll Date: Wed, 30 Oct 2013 10:53:34 +0100 Subject: [PATCH] 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. --- autoload/vimwiki/lst.vim | 18 ++++++++++++++++++ doc/vimwiki.txt | 5 ++++- ftplugin/vimwiki.vim | 6 ++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/autoload/vimwiki/lst.vim b/autoload/vimwiki/lst.vim index af01234..222e07b 100644 --- a/autoload/vimwiki/lst.vim +++ b/autoload/vimwiki/lst.vim @@ -1410,6 +1410,24 @@ function! vimwiki#lst#setup_marker_infos() "{{{ 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) "{{{ let cur_item = s:get_item(a:lnum) if cur_item.type != 0 diff --git a/doc/vimwiki.txt b/doc/vimwiki.txt index aa534e7..8a00ba1 100644 --- a/doc/vimwiki.txt +++ b/doc/vimwiki.txt @@ -471,6 +471,9 @@ i\ An inner cell in a table. ac A 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* @@ -814,7 +817,7 @@ You can nest and mix the various types: > - 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: > * Item 1 diff --git a/ftplugin/vimwiki.vim b/ftplugin/vimwiki.vim index d599ded..aeddc41 100644 --- a/ftplugin/vimwiki.vim +++ b/ftplugin/vimwiki.vim @@ -416,6 +416,12 @@ vnoremap ac :call vimwiki#base#TO_table_col(0, 1) onoremap ic :call vimwiki#base#TO_table_col(1, 0) vnoremap ic :call vimwiki#base#TO_table_col(1, 1) +onoremap al :call vimwiki#lst#TO_list_item(0, 0) +vnoremap al :call vimwiki#lst#TO_list_item(0, 1) + +onoremap il :call vimwiki#lst#TO_list_item(1, 0) +vnoremap il :call vimwiki#lst#TO_list_item(1, 1) + if !hasmapto('VimwikiAddHeaderLevel') nmap = VimwikiAddHeaderLevel endif