1

Vim 7.3 on Ubuntu 12.10

I recently installed vim from the Ubuntu software center. So far, I've installed the following vim plugins: NERDTree, rails and ack.

I'm taking a course on python and another one on Ruby on Rails. I was surprised that vim didn't recognize the languages as far as indenting goes. Checking various questions and answers on this forum, as well as checking vim help, I see that there should be a directory named 'ftplugin' in the $VIMRUNTIME directory. My $VIMRUNTIME is just the same as $HOME which is ~/, but there is no 'ftplugin' in my home directory. There's also nothing like that in ~/.vim. Does that mean I don't have any filetype plugins?

If I don't, where can I get the usual set?

Colin Keenan
  • 1,089
  • 12
  • 20
  • I'm not sure about Ubuntu but beside `.vim` in root folder, there is another .vim which is shared globally. This question may answer yours : http://stackoverflow.com/questions/7640805/vim-ubuntu-system-wide-plugin-directory . – Dzung Nguyen Oct 18 '12 at 19:47
  • I had already seen that question, and no, it doesn't answer my question. The person that asked that question didn't even have a .vim directory, but I do. I also already knew all the places vim searches for stuff. That's my point though, in all the places it searches, there's no 'ftplugin' directory and no language specific plugins except rails that I downloaded myself. Trying `which vim` tells me it's run from /usr/bin/vim. I tried `ls /usr/bin/vim*` and there are some plugin-related files there, but once again, they were for the rails plugin I downloaded myself. So, my question stands. – Colin Keenan Oct 19 '12 at 04:29

1 Answers1

6

edit

Just to be clear: upon install, Vim doesn't do anything to your home directory. The ~/.vim directory and any subdirectory are to be created by the user: it is where you put your config so you are in charge.

endedit

You must create those directories yourself, no matter what OS you are using. On UNIX-like systems (Linux, Mac OS X…) all your stuff is supposed to go into ~/.vim:

$ cd
$ mkdir .vim
$ cd .vim

Some plugins may need to be placed into specific subdirectories:

~/.vim/autoload
~/.vim/plugin
etc.

You can:

  • create those directories just like you created ~/.vim and place all the files manually
  • $ unzip the plugins right there in ~/.vim, the necessary directories are created for you
  • use some plugin manager like Pathogen or VAM or Vundle and/or a VCS…

I'd advise you to start slow. Just install everything manually: it will help you getting more comfortable with the whole thing.

Anyway, since you have already installed a bunch of (useless IMO, except rails) plugins you probably already know all that.

Vim already has the necessary ftplugins, you only need to tell Vim to "activate" them by default. Add these two lines to your ~/.vimrc (create that file if you didn't already):

filetype plugin indent on
syntax on
romainl
  • 186,200
  • 21
  • 280
  • 313
  • I had gone through the vimtutor and so already have a lot of stuff in my ~/.vimrc file, including what you listed (inside of conditionals to make sure they make since), and yet, I can't figure out where the ftplugins are. That's the whole point of my question. I mean, what if I want to modify one of those files? Where are they. You say they're included by default, and the help system says it's supposed to be in a directory called 'ftplugins', but I don't have that directory. – Colin Keenan Oct 19 '12 at 04:18
  • 3
    Vim has a lot of support files that you can find in `/usr/share/vim/vim7x`. That's where you can find the ftplugins for many languages, including Ruby and Python. **But you are not supposed to alter anything there.** All your custom stuff should go in `~/.vim`. An ftplugin is just a collection of commands and functions targeted at a specific filetype. If you only need one or two custom mappings for Python, there's no real need for putting them in a ftplugin: just leave them in your `~/.vimrc`. – romainl Oct 19 '12 at 05:35
  • 1
    If you have a lot of filetype-specific stuff in your `~/.vimrc` you should put it in an ftplugin: `~/.vim/ftplugin/python.vim`. And yes, as I wrote in the first line of my answer, you have to create that directory yourself. – romainl Oct 19 '12 at 05:41
  • Thanks. With these last two comments, this is the right answer. In my Ubuntu, it's actually ~/usr/share/vim/vim73 in case anyone was wondering what the x was at the end. – Colin Keenan Oct 19 '12 at 21:26
  • No. `~/usr` doesn't exist, it should be `/usr`. – romainl Oct 20 '12 at 06:22
  • Oops, that's what I meant. No tilde in front of /usr/share/vim/vim73 – Colin Keenan Oct 20 '12 at 23:17