Linux/Ubuntu directory location ~/.vim/syntax/ - vim

Where is the default location for the folder ~/.vim/syntax/ on a Linux system? I am trying to add a Python addon.

You are looking for the 'runtimepath' option. The documentation is pretty detailed (use :help runtimepath) but I'll try and summarize it here:
The runtimepath option contains a list of paths, separated by commas, where vim looks for plugins, syntax files, etc. On unix, the first path is $HOME/.vim/ (aka ~/.vim/), which means that Vim looks for syntax files in your home folder first before it looks anywhere else. Vim looks for your extra files by searching ~/.vim/plugin/*.vim or ~/.vim/syntax/*.vim, depending on what type of add-ons it is loading.
The next path in runtimepath is usually /usr/share/vim/. Vim will also search this folder for plugins etc (vim looks for /usr/share/vim/plugin/*.vim, etc). This folder is where you should put add-ons when you want them available to every user.
The last path in runtimepath is usually /usr/share/vim/vim72/, or whever Vim was installed to. This tells vim where to find and load add-ons which came bundled with that particular version of Vim.
Now, Most add-ons have a mechanism so that once they have been loaded from, say, your ~/.vim/syntax/ folder, they cannot be loaded from anywhere else. So even though syntax/python.vim comes bundled with Vim and is available in /usr/share/vim/vim72/syntax/python.vim, if an alternative version is instead loaded from ~/.vim/syntax/python.vim, then the bundled syntax is ignored. This is how you can override bundled add-ons using your ~/.vim/ folder, and you can also override them for everyone by putting addons in /usr/share/vim/. The other advantage of this setup is that you can always download the latest versions of the default bundled plugins without overriding any custom plugins you may have added.
If you were to put all your addons into /usr/share/vim/vim72/, you can no longer update to the latest bundled addons without overriding your custom addons, so you should be putting addons for yourself into ~/.vim/, or addons for all users into /usr/share/vim/, but never into /usr/share/vim/vim72/.

~ is a UNIX shortcut that means "the currently logged-in user's home folder", which is typically something like /users/<username>. You should be able to find that folder by executing
cd ~
mkdir -p .vim/syntax
cd .vim/syntax
The mkdir command creates the directory if it doesn't already exist.
If you want to add the syntax for multiple users, ire and curses is on a better track.

From the docs:
$VIMRUNTIME/syntax
On my (Ubuntu) machine, this is /usr/share/vim/vim72/syntax/.

/usr/share/vim/vim72/syntax/
I added the file in the above location and it is working for puppet scripting

Related

How to install twig.vim in the .vimrc file for Vim 8.1

I'm trying to get this installed in my vim for ubuntu:
https://github.com/nelsyeung/twig.vim
I downloaded the files to ~/.vim folder, but there are no instructions on what I need to put into the .vimrc file to get it activated. What steps am I missing?
I downloaded the files to ~/.vim folder,
No. If you want to use Vim new integrated plugins management, first create the pack directory with a dedicated subdirectory of your choice (let's call it git-plugins but it's really own to you and depend how you want to have things organised)
mkdir -p ~/.vim/pack/git-plugins
In that location, create one of these directories:
start for plugins you always want available when you launch Vim
opt for plugins you want to activate and deactivate manually
Last, there will be a directory for the plugin itself. So, here, you have to download the files into let's say ~/.vim/pack/git-plugins/start/twig/
instructions on what I need […] to get it activated.
Now, launch vim and type the following command:
:packloadall
Check the included manual with
:h packl
This plugin has no doc to integrate into that system. But for general cases, put the following in your ~/.vimrc, after all internal setting and before plugins dedicated settings.
packloadall
silent! helptags ALL

problems installing vim-misc and vim-session plugins on mac / macvim

When I follow github instructions for vim-misc and vim-sessions, after unzipping to /Users/<me>/.vim/misc and /Users/<me>/.vim/vim-session-master, and then restarting macvim, I get
:helptags ~/.vim/doc
E150: Not a directory: ~/.vim/doc
Also tried putting the two folders in /Users/<me>/ (where my .vimrc is) and in the two locations pointer by $VIM and $VIMRUNTIME from within macvim (/Applications/MacVim.app/Contents/Resources/vim) all to no avail.
I guess I really don't understand how running the :helptags <whatever> starts up/completes installation of these plug-ins anyway?
Before using using a plugin managers, plugins used to go directly into ~/.vim, not into ~/.vim/pluginname. That's when we ran :helptags ~/.vim/doc.
Then we had plugin manager, each with different specific way of doing things. Some even take care of registering the documentation of the plugins installed.
IMO, you'd better find a plugin manager suited to your need and use it. I remember a Q/A on vi.SE, you could start by reading it.
If you prefer to install plugins manually instead of using one of plugin managers like vim-plug or others then you should add plugin directory to your runtimepath. Place this line to your .vimrc set runtimepath+=/path/to/plugin. I would not recommend to place plugins directly to ~/.vim directory, use sub-folder instead (e.g. /Users/<you>/.vim/plugins).

How to make vim javacomplete to work?

I confess that I am a beginner in using vim and this question might be as dumb as it sounds. These are what I've done so far :
I downloaded the latest zip file format of the script from here.
I unzipped it to the .vim directory that placed the files javacomplete.vim, java_parser.vim and Reflection.java inside the ~/.vim/autoload directory by default.
The following option is set (much better, I've added it to my .vimrc file):
:setlocal omnifunc=javacomplete#Complete
java and javac are set properly in the system path variable (they work from the command line).
Assuming that that's all I need to do, pressing <C-x><C-o> (in the insert mode) doesn't do any auto-completion inside a .java file.
What am I doing wrong here?
If you're using Vim 7.2, there's a few issues related to how the plugin locates the java-based Reflection helper.
If you have .class listed in your wildignore or suffixes, then it can't actually locate the class file to execute.
I have a clone that I modified to get around that on github : https://github.com/cilquirm/javacomplete
Give that a go and see if it works for you

How to resolve these Vimball problems when I install plugins?

I don't like Vimball files in Vim but more and more plugins use Vimball to install themselves.
A month ago I installed a 64 bits OS and moved my vimfiles directory to c:\users\"my-name"
No problem. Everything works fine.
Today I wanted update a plugin (which is now in Vimball).
After sourcing the plugin (:so %)
I received a lot of errors:
Error detected while processing function vimball#Vimvall..vimball#VimballHome:
E739: Cannot create directory C:/Progra~1/Vim/vimfiles
Error detected while processing function vimball# Vimball..<SNR>119_ChgDir:
E344: Can't find directory "C:\Progra~1\Vim\vimfiles in cdpath
E472: Command failed
...and so a whole page more of these kind of errors.
What's happening and how can I resolve it?
Vimballs are extracted into the first existing directory on 'runtimepath'; based on your output, is looks like Vim doesn't recognize the location where you moved your vimfiles to, and instead defaults to the system-wide C:/Progra~1/Vim/vimfiles location, which probably is protected by Windows permissions, thereby causing the errors.
Check the output of :set runtimepath?; the first component should be your C:\Users\my-name\vimfiles; if it isn't, you need to make Vim include it, either via external means (e.g. setting the HOME environment variable), or directly in your ~/.vimrc with :set runtimepath=.... See :help runtimepath for details.
Also, check for g:vimball_home; this Vimball configuration overrides the default logic.
As a workaround (not a solution), you can pass a custom install directory to the :UseVimball command.

What is the difference between vim72 and vimfiles folder?

I am learning VIM. The VIM folder in the windows has two subdirectories VIM72 and VIMFILE. What is the difference between them? Where should I install my plugins?
Usually VIM72 (depends on the vim version) is the 'runtime' directory, I believe this is where vim is searching for all the stuff that it needs during 'runtime'. You would install your custom stuff, e.g. plugins, in your '$HOME/.vim' directory on linux (plugins in $HOME/.vim/plugin).
On windows it seems to be the vimfiles directory (you asked about VIMFILE on my windows system and vim71 it is vimfiles).
So I would try to store plugin in vimfiles\plugin directory on your system.
The difference would be that in VIM72 you would have all the runtime stuff that comes prepackaged with vim including binaries. You can install your own stuff in your vimfiles directory which will be usually searched first for stuff like syntax highlight, color schemes, plugins, documentation and so on.
You can find out the location of your vim72 directory, the location for your custom stuff like vim72/plugins, vim72/colors for colorshemes and so on, from vim do:
:echo $VIMRUNTIME
And finally, vim72 is used by vim 7.2 so when the version changes it will use different directory like vim73 and so on.
Expanding very slightly on stefan's answer:
Like he says, ~/.vim for linux-related systems, and usually vimfiles for gvim on Windows - this is your home vim directory.
You should put all of your own plugins into vimfiles to make sure that when you upgrade your vim installation you don't lose any of the custom plugins or modifications.
For example
There is a syntax file called cpp.vim in vim72/syntax.
If you now want to change a few things in this syntax file (say to add an extra keyword) you could have a copy of this syntax file in vimfiles/syntax with the additional keyword syntax rules.
Now when you upgrade vim to 7.3, you still have all of your custom plugins and settings.
If you were to instead change vim72/syntax/cpp.vim, when you next upgraded vim these files would be overwritten by the new versions and any changes that you made would be lost.
Plus, since vim72/syntax/ contains all of the original syntax files, it would be more difficult to tell which of these you had customised.
That 'vimfiles' directory is where you can install things system-wide without touching Vim's installation directory ('vim72'). The directory 'vim72' is subject to change when upgrading and a new major or minor version will use a different directory (e.g. Vim 7.1 used 'vim71' and Vim 8.0 will use 'vim80').

Resources