Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/image/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
以GTD方式使用Vim_Vim_Vimgrep_Gtd_Vim Quickfix - Fatal编程技术网

以GTD方式使用Vim

以GTD方式使用Vim,vim,vimgrep,gtd,vim-quickfix,Vim,Vimgrep,Gtd,Vim Quickfix,我想改变我记笔记的习惯 我想在目录中添加名为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

我想改变我记笔记的习惯

我想在目录中添加名为
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...
我想要的是:

  • 使用Vim(没有插件,只有内置功能;没有外部程序;在我的personnal vimrc中只有一些autocmd、映射和函数)
  • 将我所有的笔记保存在一个目录中,相信Vim和我的标记可以找到我需要的东西
  • 用一个此类命令开始使用此系统
    :GtdGrep
    ,如果需要更多,请稍后思考
模型

现在我向您介绍了我的需要,我可以开始描述我的问题了^^我想创建: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>)

我想在第一个空行之前的行上限制我的vimgrep,但我没有成功做到这一点。有什么想法吗?

首先,如果使用动态字符串作为模式,您应该知道风险。例如,您的项目名称包含
[].*()…

您可以尝试构建以下命令:

vimgrep '/\%<10l\(foo\|bar\|blah\|whatever\)' path/*

vimgrep'/\%您对我的搜索模式的评论是明智的。理想情况下,我希望能够在函数的参数中使用regexp。您提交的vimgrep命令用于搜索foo、bar或blah等。我需要的是构建一个和regexp,查看第一行,任何顺序的任何术语。有没有改进您的regexp的想法?我在几行(
\\.*
)或任何顺序(
(?=.*foo)(?=.*bar)
)上找到了一些搜索线索,但不能同时搜索这两行:/
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 '/\%<10l\(foo\|bar\|blah\|whatever\)' path/*