0

I found interesting code on GitHub at https://github.com/google/styleguide/blob/gh-pages/google_python_style.vim

I would like to use it, but when I just dropped it in my .vimrc, it interfered with editing of other kinds of code such as C. How do I associate it with Python code only?

1 Answer 1

0

That file is an "indent script", its content has nothing to do in your vimrc.

You are supposed to save it as:

  • ~/.vim/after/indent/python.vim (Unix-like systems)
  • %userprofile%\vimfiles\after\indent\python.vim (Windows)

Concretely, Vim already comes with an indent script for Python and the indent script you are trying to install depends on it. By saving it under after/, you ensure that it is sourced, automatically, after the built-in one.

4
  • If that's the case, are things in .vim/after sourced automatically somehow, or do I have to invoke it?
    – ForDummies
    Feb 16 at 0:45
  • Hmm. Now that I'm paying more attention, I fail to see anything in this code that would make it specific to Python sources. Maybe I should just ignore it.
    – ForDummies
    Feb 16 at 1:12
  • This line makes the script very much Python-specific.
    – romainl
    Feb 16 at 6:00
  • @ForDummies RE: .vim/after, it should be on your runtimepath. See :help runtimepath for all the things that can be in it which are invoked automatically or by special commands like :compiler
    – D. Ben Knoble
    Feb 16 at 15:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.