V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
kayue
V2EX  ›  Vim

Vim Auto-completion

  •  
  •   kayue · 2010-12-10 15:26:08 +08:00 · 5323 次点击
    这是一个创建于 4879 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我是 web developer

    請問大家覺得哪個 php / javascript / css auto-completion plugin 最好呢??
    12 条回复    1970-01-01 08:00:00 +08:00
    spark
        1
    spark  
       2010-12-10 15:37:45 +08:00
    snipmate?
    harryxu
        2
    harryxu  
       2010-12-10 15:40:07 +08:00
    neocomplcache 感觉不错,我一直在用
    http://www.vim.org/scripts/script.php?script_id=2620
    kayue
        3
    kayue  
    OP
       2010-12-10 15:55:09 +08:00
    我想达到的效果是跟 xcode 里的差不多
    - 按 tab 的时候,自动补完馀下字串
    - 按 esc 的时候,显示 autocomplete list

    snipmate 能做到第一项,不过没有 preview 不方便
    在试 neocomplcache 中,不过经常在 javascript/css 里 suggest php function……不好用啊,而且也没有按 tab 自动补完的效果。
    kayue
        4
    kayue  
    OP
       2010-12-10 18:36:38 +08:00
    推一推,autocomplete 很重要啦
    aligo
        5
    aligo  
       2010-12-10 20:03:38 +08:00
    第一需求snipmate可以实现

    然后autocomplete list可以用autocomplpop实现,会自动识别当前文件的语言
    kayue
        6
    kayue  
    OP
       2010-12-10 23:04:14 +08:00
    另外,有沒有辦法做到自動 close tag 的效果?例如輸入 <a> 會自動加上 </a>

    和 () {} 等等
    eth2net
        7
    eth2net  
       2010-12-10 23:21:16 +08:00
    eth2net
        8
    eth2net  
       2010-12-10 23:22:45 +08:00
    @kayue 貌似理解错了,snipmate一类插件吧。
    harryxu
        9
    harryxu  
       2010-12-10 23:24:56 +08:00
    e6nian
        10
    e6nian  
       2010-12-11 00:33:11 +08:00
    Options for auto-complete-(
    :inoremap ( ()<ESC>i
    :inoremap ) <c-r>=AutoPair(')')<CR>
    :inoremap { {}<ESC>i
    :inoremap } <c-r>=AutoPair('}')<CR>
    :inoremap [ []<ESC>i
    :inoremap ] <c-r>=AutoPair(']')<CR>
    :inoremap < <><ESC>i
    :inoremap > <c-r>=AutoPair('>')<CR>

    function! AutoPair(char)
    if getline('.')[col('.') - 1] == a:char
    return "\<Right>"
    else
    return a:char
    endif
    endf
    kayue
        11
    kayue  
    OP
       2010-12-11 15:07:27 +08:00
    @e6nian neat!

    the key mapping works great

    but not sure how the AutoPair funciton works
    kayue
        12
    kayue  
    OP
       2010-12-11 15:58:28 +08:00
    在用 Autoclose,是我想要的东西,但是不懂怎么把 keymap 改成 </

    目前需要用 <C-_> 来 trigger autoclose
    在想办法将它改为 </

    比较直觉吧
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2566 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 01:33 · PVG 09:33 · LAX 18:33 · JFK 21:33
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.