qqzsxyz / vimwiki

Automatically exported from code.google.com/p/vimwiki
0 stars 0 forks source link

Lists with sequence numbers #190

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Lists with sequence numbers

Features:
Sequence number auto generated
Indents makes sublevels
syntax highlight of sequence number

1. faefea
   1.1 faefwef
   1.2 afeafewf
       1.2.1 afeafef
2. faefaefef
   2.1 faefaewfeawf
   2.2 faefeafaewf

The sequence number filed can be Arabic numerals, Roman numerals or alphabet.

Original issue reported on code.google.com by cst...@gmail.com on 14 Mar 2011 at 12:41

GoogleCodeExporter commented 8 years ago

Original comment by habamax on 14 Mar 2011 at 1:06

GoogleCodeExporter commented 8 years ago
 just add color highlighting for the number sequence list,  as 1.1. or 1)1).
simply edit file 
$VIMRUNTIME/syntax/vimwiki_default.vim : line 77
let g:vimwiki_rxListNumber = '^\s*#\s'
change it to:
let g:vimwiki_rxListNumber = '^\s*\%(\d\+[\.)]\)\+\s'

I also changed the '#' to the rxListBullet
let g:vimwiki_rxListBullet = '^\s*\%(\*\|-\|#\)\s'

Original comment by rykk...@gmail.com on 29 Mar 2011 at 9:03

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Hey! 
I'm now use this function to Auto adding numberd list item with <c-cr> and 
<c-kEnter>
Hope if this helps anyone that need it.

"{{{auto list item 
inoremap <expr> <C-CR>  "\<CR>".AutoListItem('.')
inoremap <expr> <C-Kenter>  "\<CR>".AutoListItem('.')
func! AutoListItem(line)
      let lastline=getline(line(a:line))
      if lastline=~ '^\s*\%(\d\+\.\)\+\s'
          let lastnum=substitute(lastline,'^\s*\(\d\+\.\)\+\s.*$','\1','')
          let all_num=substitute(lastline,'^\s*\(\(\d\+\.\)\+\)\s.*$','\1','')
          let plus_num=str2nr(substitute(lastnum,'\(\d\+\)\.','\1',''))+1
          let plus_line=substitute(all_num,'\d\+\.$',plus_num.'.','') 
          return plus_line." "
      else 
          return ""
      endif
return ""
endfunc
"}}}

Original comment by rykk...@gmail.com on 2 Apr 2011 at 7:29

GoogleCodeExporter commented 8 years ago
the list item looks as follows:
1.
1.1.
2.
2.1.
2.2.

Original comment by rykk...@gmail.com on 2 Apr 2011 at 7:32

GoogleCodeExporter commented 8 years ago
"{{{auto list item 
inoremap <expr> <C-CR>  "\<CR>".AutoListItem('.')
inoremap <expr> <C-Kenter>  "\<CR>".AutoListItem('.')
func! AutoListItem(line)
      let line=getline(line(a:line))
      if line=~ '^\s*\%(\d\+\.\)\+\s'
          let end_num=matchstr(line,'\d\+\.\s')
          let all_num=matchstr(line,'\(\d\+\.\)\+')
          let plus_num=str2nr(matchstr(end_num,'\d\+'))+1
          let plus_line=substitute(all_num,'\d\+\.$',plus_num.'.','') 
          return plus_line." "
      else 
          return ""
      endif
endfunc
"}}}

This one may have a more clear look

Original comment by rykk...@gmail.com on 2 Apr 2011 at 9:45

GoogleCodeExporter commented 8 years ago
Having the numbers in the file explicitly has some advantages, but it is a 
little harder to input and much, much harder to edit (insertions into the 
list...). That is why the explicit numbers are good for an export format (they 
are presentation), but not for the input format (which is markup).

Besides, every writing script/culture has typically several different ways of 
numbering sequences, so you would be soon into supporting dozens of 
conventions. It would be nice to be able to influence which one is used for the 
output, though.

How about defining some functions and mappings that would allow people to see 
which item is which when they need it, instead of changing the input? GVim/Vim 
has tooltips of a sort (:he balloonexpr) and also "signs" feature (:he signs) 
--- the latter one could be made to display the numbers of items for the two 
top levels.

Original comment by tpospi...@gmail.com on 2 Apr 2011 at 10:50