0

Sorry I searched for answer to the above question but none matched my exact situation. I am a beginner at vim and trying to set it up for C++ programming. I am using Xubuntu 14.04 and installed vim using sudo-apt and I also installed YouCompleteMe plugin using the following

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

And YouCompleteMe works perfectly and then I installed NERDTree by simply downloading the zip file at the link http://www.vim.org/scripts/script.php?script_id=1658 and extracting it in ~/.vim folder and NERDTree also works fine. Then I installed pathogen for vim using the instructions given at the link https://github.com/tpope/vim-pathogen and my ~/.vimrc looks like

" 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

Then I installed SnipMate using the instruction for Pathogen given at vim-snipmate repository by Garbas (Sorry I couldn't post more than two links) And it looks like the snipmate plugin is active in vim because when I do :imap I get the following output

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

So according to the above output the snipmate should trigger for me when I enter the shortcut and press Ctrl+R but it doesn't work. However when I press Ctrl+R+Tab I see a list of snippets but they don't work when I select any one of them. For example cpp.snippets in /home/username/.vim/bundle/vim-snippets/snippets/ has an entry like

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

and when I press Ctrl+R+Tab I see a list in which I can see fori but when I select fori from the list it just appears as fori verbatim in my vim file. I am really not sure what else to try to make it work. I would really appreciate any help to get SnipMate working with vim.

hellfragger
  • 143
  • 1
  • 4
  • 12
  • You have to find what you want from the list and then press the Ctrl+R – Alon Jul 27 '15 at 01:07
  • I tried that and it still doesn't work! Thanks for the reply though – hellfragger Jul 27 '15 at 02:30
  • 2
    Please try to understand what you're doing before making more random changes. VAM is a plugin manager for Vim. If you install it you have to install all other plugins though it. You don't need to install YCM with `apt-get`, you should _only_ install it with VAM. Same for NERDTree: you have to install it with VAM, rather than just extract it in your `~/.vim` (it works if you just drop it there, but it messes up VAM). Pathogen is a different package manager, and it conflicts with VAM. You can use either VAM or Pathogen, not both. As for SnipMate, you have to install that with VAM too. – Sato Katsura Jul 27 '15 at 05:24
  • So just to be clear, should I remove the NERDTree folder ,SnipMate folder and then Pathogen from `~/.vim` folder and then install NERDTree and SnipMate using VAM? Also is there a reference for beginners which tells how to install these plugins using VAM? Thanks again for the reply and suggestions, learning new things everyday. – hellfragger Jul 27 '15 at 15:48
  • Pretty much, yes. You need to remove the plugins you installed manually and install them with VAM. You might need to make an exception for YCM and install it with `apt-get` though (and remove it from VAM), since it needs compiled binaries. Plugin management for Vim is a huge mess, for historic reasons. There are several competing plugin managers, but VAM is a relatively headache-free choice for a beginner (provided that you play by its rules). It's probably a good idea to start with the [docs](https://github.com/MarcWeber/vim-addon-manager/blob/master/doc/vim-addon-manager-getting-started.txt) – Sato Katsura Jul 27 '15 at 16:13
  • Thank you very much. I will take a look at it and then try to reinstall NERDTree and SnipMate and see if it works then or not. – hellfragger Jul 27 '15 at 16:34
  • @SatoKatsura The VAM being used in this case is for managing addons installed through Debian packages, not MarcWeber's VAM. – jamessan Jul 29 '15 at 17:19
  • @hellfragger I would really recommend not copying `/etc/vim/vimrc` to `~/.vimrc`. The system-wide vimrc is already being loaded, so by copying its contents into your personal vimrc, you're now running everything twice. – jamessan Jul 29 '15 at 17:21

1 Answers1

0

So I finally figured out the issue, since I had YouCompleteMe installed its Tab function conflicted with Tab function of SnipMate. I changed the Triger to and it seems to work now.

hellfragger
  • 143
  • 1
  • 4
  • 12