我想以记笔记的方式改变我的习惯。
我希望在目录中添加名为YYYYmmddHHiiss.txt
的文件并以这种方式启动它们:
=Call somebody (title of my note)
@work (context of my note)
!todo (type of the note, I'll use !inbox, !todo, !waiting, !someday and !reference, each one his habit)
#project_name
#call
#Name of the person
#other tags if needed...
Details...
我想要的是:
:GtdGrep
命令开始使用此系统,并在一段时间内考虑是否需要更多。模型
:GtdGrep !todo @work
:GtdGrep !inbox
:GtdGrep @waiting @home
:GtdGrep !todo @work #this_project
:GtdGrep #name_of_a_co-worker #this_project
既然我已经向你介绍了我的需求,我就可以开始描述我的问题^^我想在GtdGrep命令背后创建函数但是有很多东西我无法收集......这是我的。草案
let gtd_dir=expand($HOME)."/Desktop/notes"
function! GtdGrep(...)
execute "silent! vimgrep /\%<10l".join(a:000, "\\_.*")."/j ".gtd_dir."/**"
execute "copen"
endfunction
command! -nargs=* GtdGrep call GtdGrep(<f-args>)
\%<10l
在前9行中查找我的标签,但就是这样。\_.*
regexp在几行上执行grep,这是用于返回行的。/^=
之后)。我认为有可能使用^=\zs.*\ze
,但在单个vimgrep中对我来说太过分了!修改
我通过在之前的结果上执行连续的vimgrep来解决我的“AND”vimgrep问题。这是一个很好的解决方案吗?
let gtd_dir=expand($HOME)."/Desktop/notes"
function! GtdGrep(...)
let dest = g:gtd_dir."/**"
for arg in a:000
execute "silent! vimgrep /^".arg."$/j ".dest
let dest = []
let results = getqflist()
if empty(results)
break
else
for res in results
call add(dest, bufname(res.bufnr))
endfor
let dest = join(dest, ' ')
endif
endfor
" Last vimgrep to focus on titles before displaying results
let results = getqflist()
if !empty(results)
echom dest
execute "silent! vimgrep /\\%<10l^=.*/j ".dest
execute "copen"
else
echom "No results"
endif
endfunction
command! -nargs=* GtdGrep call GtdGrep(<f-args>)
我想在第一个空行之前限制我的vimgrep,但我没有成功。有什么想法吗?
答案 0 :(得分:0)
首先,如果您使用动态字符串作为模式,您应该知道风险。例如。您的project_name包含[].*()...
你可以尝试的是,建立这个命令:
vimgrep '/\%<10l\(foo\|bar\|blah\|whatever\)' path/*