0
3

More than 5 years have passed since last update.

Vim で howm

Last updated at Posted at 2017-04-30

概要

qfixhowm を使うのが最善だろうけれど、使わない機能も多いのでメモ書き、検索に特化して他のプラグインで代用してみた。

syntax

hokorobi/vim-howm-syntax-mini
qfixhowm から一部 syntax のみを抜き出し。

新規作成

thinca/vim-template を使用。

template.howm
:% s/<+DATETIME+>/\=strftime('%Y-%m-%d %H:%M')/g
:if search('<+CURSOR+>')
:  normal! "_da>
:endif
= <+CURSOR+>
[<+DATETIME+>]

(実際にはキーマップと関数は別ファイルに書いている。)

function! vimrc#EditHowmNew(dir) abort
  let dir = a:dir.strftime('/%Y/%m')
  if isdirectory(dir) == 0
    call mkdir(dir, 'p')
  endif
  let file = strftime('/%Y%m%d%H%M%S.howm')
  execute 'edit '.dir.file
  TemplateLoad
  " 行末尾追加でインサートモードへ
  startinsert!
endfunction
nnoremap <Leader>,c :call vimrc#EditHowmNew(g:howm_dir)<CR>

タイトル検索

Shougo/denite.nvim を使用。

" 2017-03-30 現在の Denite では Windows で grep にディレクトリを渡すとエラーになる場合があるので cd する
function! vimrc#DeniteGrepHowm() abort
  execute 'cd '.g:howm_dir
  Denite -resume -buffer-name=denite-howm -cursor-wrap grep:::^=\\s
endfunction
nnoremap <Leader>,, :call vimrc#DeniteGrepHowm()<CR>

こちらはあまり使っておらず、Paper Plane xUI で peco を使ってフォルダ配下を検索 - Qiita でファイラーから peco を使うことが多い。peco だと migemo が使えるので。

最近開いたファイルを開く

プレビューを使いたいので CtrlP でなく Shougo/neomru.vim + denite.nvim を使用。

nnoremap <Leader>,u :<C-u>Denite file_mru -auto-preview -input=howm<CR>
0
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
3