1

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?

Vivian De Smedt
  • 16,336
  • 3
  • 18
  • 37
ForDummies
  • 111
  • 2

1 Answers1

1

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.

romainl
  • 40,486
  • 5
  • 85
  • 117
  • If that's the case, are things in .vim/after sourced automatically somehow, or do I have to invoke it? – ForDummies Feb 16 '23 at 00: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 '23 at 01:12
  • This line makes the script very much Python-specific. – romainl Feb 16 '23 at 06: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 '23 at 15:30