derekwyatt / vim-fswitch

Vim plug for switching between companion source files (e.g. ".h" and ".cpp")
179 stars 57 forks source link

Add fswitchfnames option that allows mutating the base filename when looking for a companion file. #1

Closed thesamet closed 13 years ago

thesamet commented 13 years ago

Hi Derek,

I've implemented a new feature (that is useful at least for me) and hope that you can integrate it.

The idea is that I would like to use FSwitch for switching between implementation and test code. For SomeFile.scala my test file would be called SomeFileTest.scala. It would also be in a different directory (but b:fswitchlocs takes care of that). So I thought to introduce a new option that allows substitution over the base filename. Here is how I use it:

au FileType scala let b:fswitchdst = 'scala'

" Matches scala files that do not end with Test.scala
au BufEnter *\(Test\)\@!.scala let b:fswitchlocs = 'reg:+/main/scala+/test/scala/+' | let b:fswitchfnames='/$/Test/'

" Matches scala files that do end with Test.scala
au BufEnter *Test.scala let b:fswitchlocs = 'reg:+/test/scala+/main/scala/+' | let b:fswitchfnames='/Test$//'
derekwyatt commented 13 years ago

Cheers. I'm going to merge this in after marginal testing on my part. With luck there are no issues.

thesamet commented 13 years ago

Thanks