【问题标题】:Vim snipMate installed with pathogen not triggeringVim snipMate 安装时没有触发病原体
【发布时间】:2015-10-17 01:52:53
【问题描述】:

抱歉,我搜索了上述问题的答案,但没有一个符合我的确切情况。我是 vim 的初学者,并试图将其设置为 C++ 编程。我正在使用 Xubuntu 14.04 并使用 sudo-apt 安装了 vim,我还使用以下方法安装了 YouCompleteMe 插件

apt-get install vim-youcompleteme
apt-get install vim-addon-manager
vam install youcompleteme

YouCompleteMe 运行良好,然后我通过简单地下载链接 http://www.vim.org/scripts/script.php?script_id=1658 的 zip 文件并将其解压缩到 ~/.vim 文件夹中来安装 NERDTree,NERDTree 也可以正常工作。然后我使用链接https://github.com/tpope/vim-pathogen 中给出的说明为 vim 安装了病原体,我的 ~/.vimrc 看起来像

" All system-wide defaults are set in $VIMRUNTIME/debian.vim and sourced by
" the call to :runtime you can find below.  If you wish to change any of those
" settings, you should do it in this file (/etc/vim/vimrc), since debian.vim
" will be overwritten everytime an upgrade of the vim packages is performed.
" It is recommended to make changes after sourcing debian.vim since it alters
" the value of the 'compatible' option.

" This line should not be removed as it ensures that various options are
" properly set to work with the Vim-related packages available in Debian.
runtime! debian.vim

" Uncomment the next line to make Vim more Vi-compatible
" NOTE: debian.vim sets 'nocompatible'.  Setting 'compatible' changes numerous
" options, so any other options should be set AFTER setting 'compatible'.
"set compatible

" Vim5 and later versions support syntax highlighting. Uncommenting the next
" line enables syntax highlighting by default.
if has("syntax")
  syntax on
endif

execute pathogen#infect()

" If using a dark background within the editing area and syntax highlighting
" turn on this option as well
set background=dark

" Uncomment the following to have Vim jump to the last position when
" reopening a file
"if has("autocmd")
"  au BufReadPost * if line("'\"") > 1 && line("'\"") <= line("$") | exe "normal! g'\"" | endif
"endif

" Uncomment the following to have Vim load indentation rules and plugins
" according to the detected filetype.
"if has("autocmd")
"  filetype plugin indent on
"endif

" The following are commented out as they cause vim to behave a lot
" differently from regular Vi. They are highly recommended though.
set showcmd     " Show (partial) command in status line.
set showmatch       " Show matching brackets.
set ignorecase      " Do case insensitive matching
set smartcase       " Do smart case matching
set incsearch       " Incremental search
set autowrite       " Automatically save before commands like :next and :make
set hidden      " Hide buffers when they are abandoned
set mouse=a     " Enable mouse usage (all modes)
set exrc

" Source a global configuration file if available
if filereadable("/etc/vim/vimrc.local")
  source /etc/vim/vimrc.local
endif

然后我使用 Garbas 在 vi​​m-snipmate 存储库中给出的 Pathogen 指令安装了 SnipMate(抱歉,我不能发布两个以上的链接)而且看起来 snipmate 插件在 vim 中是活动的,因为当我这样做时 :imap我得到以下输出

i  <Nul>       * <C-X><C-O><C-P>
i  <Up>        * pumvisible() ? "\<C-P>" : "\<Up>"
i  <Down>      * pumvisible() ? "\<C-N>" : "\<Down>"
i  <S-Tab>     * pumvisible() ? "\<C-P>" : "\<S-Tab>"
i  <Plug>snipMateShow * <C-R>=snipMate#ShowAvailableSnips()<CR>
i  <Plug>snipMateBack * <C-R>=snipMate#BackwardsSnippet()<CR>
i  <Plug>snipMateTrigger * <C-R>=snipMate#TriggerSnippet(1)<CR>
i  <Plug>snipMateNextOrTrigger * <C-R>=snipMate#TriggerSnippet()<CR>
i  <Tab>       * pumvisible() ? "\<C-N>" : "\<Tab>"
i  <C-R><Tab>    <Plug>snipMateShow
Press ENTER or type command to continue

所以根据上面的输出,当我输入快捷方式并按 Ctrl+R 时,snipmate 应该为我触发,但它不起作用。但是,当我按 Ctrl+R+Tab 时,我会看到一个 sn-ps 列表,但是当我选择其中任何一个时它们都不起作用。例如,/home/username/.vim/bundle/vim-snippets/snippets/ 中的 cpp.sn-ps 有一个类似

的条目
# for i
snippet fori
    for (int ${2:i} = 0; $2 < ${1:count}; $2${3:++}) {
        ${4}
    }

当我按 Ctrl+R+Tab 时,我会看到一个列表,其中我可以看到 fori 但是当我从列表中选择 fori 时,它在我的 vim 中逐字显示为 fori文件。我真的不确定还有什么可以让它发挥作用。对于让 SnipMate 使用 vim 的任何帮助,我将不胜感激。

【问题讨论】:

  • 你必须从列表中找到你想要的然后按Ctrl+R
  • 我试过了,还是不行!感谢您的回复
  • 在进行更多随机更改之前,请尝试了解您在做什么。 VAM 是 Vim 的插件管理器。如果你安装它,你必须安装所有其他插件。您不需要使用apt-get 安装 YCM,您应该使用 VAM 安装它。 NERDTree 也是如此:您必须使用 VAM 安装它,而不是仅将其提取到您的 ~/.vim 中(如果您将其放在那里,它可以工作,但它会弄乱 VAM)。 Pathogen 是一个不同的包管理器,它与 VAM 冲突。您可以使用 VAM 或 Pathogen,不能同时使用两者。至于 SnipMate,您也必须使用 VAM 安装它。
  • 所以为了清楚起见,我是否应该从~/.vim 文件夹中删除 NERDTree 文件夹、SnipMate 文件夹和 Pathogen,然后使用 VAM 安装 NERDTree 和 SnipMate?还有一个初学者参考,告诉如何使用 VAM 安装这些插件?再次感谢您的回复和建议,每天都在学习新事物。
  • 差不多,是的。您需要删除手动安装的插件并使用 VAM 安装它们。您可能需要为 YCM 设置一个例外并使用 apt-get 安装它(并将其从 VAM 中删除),因为它需要编译的二进制文件。由于历史原因,Vim 的插件管理非常混乱。有几个相互竞争的插件管理器,但对于初学者来说,VAM 是一个相对轻松的选择(前提是你遵守它的规则)。从docs开始可能是个好主意

标签: c++ vim code-snippets snipmate pathogen


【解决方案1】:

所以我终于解决了这个问题,因为我安装了 YouCompleteMe 的 Tab 功能与 SnipMate 的 Tab 功能冲突。我将触发器更改为,它现在似乎可以工作了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多