Loading google.vim indent file in Vim

I am attempting to use the google.vim (and on vim.org) indent style for my c++ project, but I can't seem to load it. I installed google.vim using vundle and opened up a cpp file and noticed that my tabstops, shiftwidths, etc did not change. If you set global ts and sw parameters, are they not overwritten? How do you force a certain indention when editing a file in vim? I want everything in my vimrc file to be overwritten by the google.vim file when I edit a cpp file.

Running the :filetype command in vim reveals this information:

      detection:ON plugin:ON indent:ON

The bottom line is that I don't understand how to tell vim to use my google.vim file located under ~/.vim/vundle/google.vim/indent/google.vim. From what I have read, vim detects that filetype of your current file and uses the appropriate .vim file for syntax and indentation. So would I then have to rename my google.vim file to something like cpp.vim?

In most cases I like to use a tabstop of 3 and a shiftwidth of 3, so I set these in my .vimrc file. However, when I edit a cpp file, I want all my settings to be changed from what I have set globally to what the google.vim file sets.


You must rename the file from google.vim to cpp.vim , as indicated in the description of the plugin on vim.org.

General explanation:

Adding filetype plugin indent on to your ~/.vimrc allows Vim to detect the filetype of the files you edit (usually based on the file extention) and source filetype-specific plugins and indent scripts.

The idea is simple: you edit a file with {{LANGUAGE}} filetype and Vim tries to source any ftplugin/{{LANGUAGE}}.vim and indent/{{LANGUAGE}}.vim it finds in your runtimepath .

Because the filetype of your file is cpp , Vim will blissfully ignore your google.vim indent script so… you must rename it to cpp.vim for it to work.

Or you could rename all your C++ files foobar.google and teach Vim to recognize *.google files but, well… it doesn't sound right ;-)

链接地址: http://www.djcxy.com/p/8728.html

上一篇: Vim在复制时缩进每行代码

下一篇: 在Vim中加载google.vim缩进文件