Skip to content

Instantly share code, notes, and snippets.

@koturn
Created February 10, 2018 02:04
Show Gist options
  • Save koturn/3f3abaf926c8433fd580491ed55aae94 to your computer and use it in GitHub Desktop.
Save koturn/3f3abaf926c8433fd580491ed55aae94 to your computer and use it in GitHub Desktop.
Ctrl-Xの補完,マーク位置,レジスタ内容のヒントを表示するキーマッピング
if &compatible
set nocompatible
endif
function! s:hint_n_m() abort " {{{
redir => str
:marks
redir END
echo str
return 'm' . nr2char(getchar())
endfunction " }}}
nnoremap <expr> m <SID>hint_n_m()
function! s:hint_n_quote() abort " {{{
redir => str
:marks
redir END
echo str
return '`' . nr2char(getchar())
endfunction " }}}
nnoremap <expr> ` <SID>hint_n_quote()
nnoremap <expr> ' <SID>hint_n_quote()
function! s:hint_n_doublequote() abort " {{{
redir => str
:registers
redir END
echo str
return '"' . nr2char(getchar())
endfunction " }}}
nnoremap <expr> " <SID>hint_n_doublequote()
let s:compl_key_dict = {
\ char2nr("\<C-l>"): "\<C-x>\<C-l>",
\ char2nr("\<C-n>"): "\<C-x>\<C-n>",
\ char2nr("\<C-p>"): "\<C-x>\<C-p>",
\ char2nr("\<C-k>"): "\<C-x>\<C-k>",
\ char2nr("\<C-t>"): "\<C-x>\<C-t>",
\ char2nr("\<C-i>"): "\<C-x>\<C-i>",
\ char2nr("\<C-]>"): "\<C-x>\<C-]>",
\ char2nr("\<C-f>"): "\<C-x>\<C-f>",
\ char2nr("\<C-d>"): "\<C-x>\<C-d>",
\ char2nr("\<C-v>"): "\<C-x>\<C-v>",
\ char2nr("\<C-u>"): "\<C-x>\<C-u>",
\ char2nr("\<C-o>"): "\<C-x>\<C-o>",
\ char2nr('s'): "\<C-x>s",
\ char2nr("\<C-s>"): "\<C-x>s"
\}
let s:hint_i_ctrl_x_msg = join([
\ '<C-l>: While lines',
\ '<C-n>: keywords in the current file',
\ "<C-k>: keywords in 'dictionary'",
\ "<C-t>: keywords in 'thesaurus'",
\ '<C-i>: keywords in the current and included files',
\ '<C-]>: tags',
\ '<C-f>: file names',
\ '<C-d>: definitions or macros',
\ '<C-v>: Vim command-line',
\ "<C-u>: User defined completion ('completefunc')",
\ "<C-o>: omni completion ('omnifunc')",
\ "s: Spelling suggestions ('spell')"
\], "\n")
function! s:hint_i_ctrl_x() abort " {{{
echo s:hint_i_ctrl_x_msg
let c = getchar()
return get(s:compl_key_dict, c, nr2char(c))
endfunction " }}}
inoremap <expr> <C-x> <SID>hint_i_ctrl_x()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment