From 2d689127908c429a29807b3b151abb13d73aab6e Mon Sep 17 00:00:00 2001 From: Jersey Date: Sun, 28 Jun 2020 14:19:40 -0500 Subject: Added the ability to uncheck --- ftplugin/markdown_bujo.vim | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'ftplugin') diff --git a/ftplugin/markdown_bujo.vim b/ftplugin/markdown_bujo.vim index 22bdd19..2330b35 100644 --- a/ftplugin/markdown_bujo.vim +++ b/ftplugin/markdown_bujo.vim @@ -1,6 +1,21 @@ +" markdown_bujo.vim - A minimalist todo list manager +" Maintainer: Jersey Fonseca +" Version: 0.5 + +" SearchCheck() searches for whether or not BujoCheck... was called on a +" checked or unchecked task. We need to call search() twice with and without +" the 'b' tag because search() only allows you to search forward or backwards, +" not both ways. +" +" search() returns 0 if it the pattern was not found +function SearchCheck() + return (search('\[\]', 'nc', line('.')) || search('\[\]', 'nbc', line('.'))) +endfunction + " Edit markdown lists " Add and remove bullets with ease +" If we are already checked then we uncheck +nnoremap BujoChecknormal SearchCheck() ? ':.s/\[\]/\[x\]' : ':.s/\[x\]/\[\]' nnoremap BujoAddnormal i-[] -nnoremap BujoChecknormal :.s/\[\]/\[x\] inoremap BujoAddinsert -[] -inoremap BujoCheckinsert :.s/\[\]/\[x\] +inoremap BujoCheckinsert SearchCheck() ? ':.s/\[\]/\[x\]' : ':.s/\[x\]/\[\]' -- cgit v1.2.3