commit 140d32fcddce8bbbfd069e529a947f7c3bbc3bf5
parent e9b1b66807d2affdbe1a12f983d2d9572ad55f79
Author: EinfachToll <istjanichtzufassen@googlemail.de>
Date: Wed, 30 Oct 2013 10:53:34 +0100
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.
Diffstat:
3 files changed, 28 insertions(+), 1 deletion(-)
diff --git 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
@@ -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
@@ -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>
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')
nmap <silent><buffer> = <Plug>VimwikiAddHeaderLevel
endif