Skip to content

Instantly share code, notes, and snippets.

@nukino
Created January 9, 2012 15:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nukino/1583365 to your computer and use it in GitHub Desktop.
Save nukino/1583365 to your computer and use it in GitHub Desktop.
helpgrep修正スクリプト
func! FuncJHelpgrep(strg, type)
if ( &enc != "utf-8" )
if ( !has('iconv') )
echohl ErrorMsg | echomsg 'Not support iconv' | echohl None
return
endif
if ( a:type == 0 )
let scmd = "helpgrep "
else
let scmd = "lhelpgrep "
endif
"検索結果をUTF-8に変換
let sfind = iconv(a:strg, &enc, "utf-8")
exe scmd . sfind
if ( a:type == 0 )
let flist = getqflist()
else
"ヘルプウィンドウを検索
let l:bufnrlist = tabpagebuflist()
let nr_helpw = -1
for i in bufnrlist
if ( getbufvar(i, "&filetype") == "help" )
let nr_helpw = bufwinnr(i)
break
endif
endfor
if ( nr_helpw == -1 )
echohl ErrorMsg | echomsg 'Not found Help Window' | echohl None
return
else
let flist = getloclist(nr_helpw)
endif
endif
for l in flist
let l.text = iconv(l.text, "utf-8", &enc)
endfor
if ( a:type == 0 )
call setqflist(flist)
else
call setloclist(nr_helpw, flist)
endif
else
helpgrep a:strg
endif
endfunc
"コマンド
command! -nargs=1 Jhelpg call FuncJHelpgrep(<q-args>, 0)
command! -nargs=1 Jlhelpg call FuncJHelpgrep(<q-args>, 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment