如何在函数中输入':norm'

时间:2017-03-21 17:53:12

标签: vim

我想在行中选择textobject,之后我想在命令行中预先输入:norm,等待我的进一步订单

function! s:SelectAndEnterNorm(...)
  " I am selecting textobject that was entered after ,.
  silent exe "normal! '[V']"

  " and now I want that the string ":norm " was entered 
  " in command line as if I entered it
  " I have tried this but it doesnt work, without errors
  silent exe "normal! :norm"
endfunction

nmap <silent> <leader>. :set opfunc=<SID>SelectAndEnterNorm<CR>g@

" same with visual mode
vnoremap <leader>. :norm<space>

并且

1 个答案:

答案 0 :(得分:1)

感谢Randy Morris

function! s:SelectAndEnterNorm(...)
  silent exe "normal! '[V']"
  call feedkeys(":norm ")
endfunction

vnoremap <leader>. :norm<space>
nmap <silent> <leader>. :set opfunc=<SID>SelectAndEnterNorm<CR>g@