Weighted Checkboxes, alternative syntax

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Weighted Checkboxes, alternative syntax

Carsten Hey-4
Hi.

I use the new checkbox plugin with support for weighted checkboxes for
some time now.  It is really a great feature, thanks a lot.

One minor drawback in the second posted syntax [2] is that the checkbox
itself and the percentage are at the beginning of the line and the
weight is at the end.  This makes it hard to detect the weight at the
first sight, especially when nowrap is set in conjunction with long
lines.  The first posted syntax [1] might look confusing for people who
do not know vimoutliner.  So I tried to address both by creating an
alternative syntax.  It matches different variants:

    1. "n%w" (same as used in [1])
    2. "n%*w"
    3. "n% * w" (the number of whitespaces is arbitrary)

I attached the updated script and diffs to the previous versions.


The attached syntax file vo_base_syntax.vim includes syntax highlighting
for checkboxes, e.g. different colors for done and undone checkboxes,
the weight is also highlighted.  Besides the checkbox stuff it is rather
simple, it just alternates between black and dark grey for different
levels.


I noticed that in nearly all cases I only need ,,cx and ,,c% as commands to
deal with checkboxes, so I mapped shift-tab accordingly:

" Uncomment to toggle, create or recalculate checkboxes with shift-tabulator.
nnoremap <buffer> <silent> <expr> <S-Tab> ":silent normal <LocalLeader>"
\       . ( getline(".") =~ "^\t*[[][X_][]] ." ? "cx<CR>j"   : "c%<CR>j" )
inoremap <buffer> <silent> <expr> <S-Tab> "<ESC>m`:silent normal <LocalLeader>"
\       . ( getline(".") =~ "^\t*[[][X_][]] ." ? "cx<CR>``a" : "c%<CR>``4la" )

At least in Debian the termcap entry for shift tab in GNU screen is
missing, so I added to following lines to my .vimoutlinerrc.  Please
note that  includes an escape, and can be inserted by pressing
<C-v><S-Tab>.

" If the above mapping does not work for you in GNU screen try uncommenting the
" following line.
if &term == 'screen' && !has('gui_running') | set <S-Tab>= | endif


Regards
Carsten


[1] http://lists.vimoutliner.org/pipermail/vimoutliner/2008-September/002276.html
[2] http://lists.vimoutliner.org/pipermail/vimoutliner/2008-September/002285.html


[Consider everything in this mail (except the parts where I'm not
copyright holder) to be licensed under the GNU GPL version 2 or
later, or (at your option) under any other DFSG-free license.]

_______________________________________________
VimOutliner mailing list
[hidden email]
http://www.lists.vimoutliner.org/mailman/listinfo/vimoutliner

diff_r1_r3.txt (1K) Download Attachment
diff_r2_r3.txt (1K) Download Attachment
vo_checkbox_weighted_r3.vim (13K) Download Attachment
vo_base_syntax.vim (1K) Download Attachment