0

I enabled Linux coding style in $HOME/.vimrc as:

let g:linuxsty_patterns = [ '/home/mark/sample1', '/home/mark/sample2', '/home/mark/sample3' ]

But is it possible to enable it per file? As I know, it is possible to pass vim settings in comments in C files. Also, I tried to manually set linuxsty_patterns while editing opened file in vim, but it didn't take any effect.

What am I doing wrong?

2 Answers 2

1

You should have stated that your question relates to a specific plugin.

Those questions are better addressed directly to the plugin maintainer.

Now, reading its source code, it seems you just need to specific a list of regexes that match the source files to which you which to apply the plugin setting. It seems this is the only control you could expect with this plugin.

Sign up to request clarification or add additional context in comments.

5 Comments

The plug-in also registers a :LinuxCodingStyle command... So you could potentially use it to enable it on a file not included in the linuxsty_patterns list. (For example, you could use that to detect a Linux git checkout or maybe look for a well known file in a Linux tree to decide whether to adopt the style.)
@filbranden, I tried to call this command from vimrc as call LlinuxCodingStyle() but it keeps complainig: E117: Unknown function: LinuxCodingStyle
@Mark Plug-ins are loaded after your vimrc, so typically you can call functions defined in plug-ins from autocmd's only. In any case, you should use an autocmd, since you need to call that per buffer, doing so for the first buffer opened in Vim might not be enough...
Also, the one available to you is a command, not a function. The function is private, available to the script's internals only.
@Mark Depends on what exactly you mean... On which condition would you like to enable Linux style? I recommend you update your question to make it more specific/explicit about what exactly you're trying to accomplish...
0

I don't see file types in your example, but I use autogroup like this.

augroup go
  autocmd!
  " Write file before :make, :GoBuild, :GoTest|Func, :GoRun
  autocmd FileType go set autowrite
  " go fmt uses tabs for indentation, ts and sw only affect viewer
  autocmd FileType go setlocal noexpandtab tabstop=4 shiftwidth=4
  " Enable Vim syntax highlighting for Go template files
......
augroup END

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.