vim 怎样编写 可以在命令行交互 的函数 ?
phpcn_u1582
phpcn_u1582 2017-05-16 16:38:35
0
1
541

nnoremap <leader>c :Ack '^class ' <c-r>=&path<cr><home><right><right><right><right><right><right><right><right><right><right><right><right>

大意是在 &path 路径下使用 Ack 搜索 pattern.

这条映射中的 n*<right> 丑死了, 可以怎样优化下?

经过社区帮助, 我把最终的方法放到下面:

" help input

function! AckClass()
    let l:classPattern = input('Pattern: ')
    execute " Ack '^class " . l:classPattern . "' " . &path
endfunction

command! AckClass call AckClass()
phpcn_u1582
phpcn_u1582

全部回复(1)
PHPzhong

不知道你要交互到什么程度

function! ChangeFileencoding()
    let encodings = ['GB18030', 'GBK', 'cp936', 'utf-8', 'big5', "latin1", "euc-kr", "euc-jp", "ucs-bom", "shift-jis"]
    let prompt_encs = []
    let index = 0
    while index < len(encodings)
        call add(prompt_encs, index.'. '.encodings[index])
        let index = index + 1
    endwhile
    let choice = inputlist(prompt_encs)
    if choice >= 0 && choice < len(encodings)
        execute 'e ++enc='.encodings[choice].' %:p'
    endif
endf

这是我的vimrc的换编码打开文件的函数,会展现一个选项列表,供你参考

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!