One of the most boring parts during working with F# Script files is external references. We need to write a lot of directives with paths to the required files.
New Visual Studio 2013 can help here a bit. A new ‘Send to Interactive‘ button is available there. Now you can avoid typing an extra command to load references for interactive execution of a small part of your application. But what to do if F# script is our goal?
If you are VS2012 user, then one nice plugin from Tao Liu is available for you “AddReferenceInFSI“. It is a really nice extension, but it is still not a silver bullet.
What do real gurus do in such a situation? Tomas Petricek has shared one typing trick. You can find it in his latest Channel 9 video “Understanding the World with F#” starting from 4:40. What?!? How did he open file picker inside the source code file, chose file that he wanted and inserted relative path to the file directly in code? Why do I always type these long and boring paths if it can be done so easy? Today the truth will come true!
Thomas was so kind and revealed the secret of this trick:
@sergey_tihon Hehe… just type the path in the open file dialog (Ctrl+O) and then select it, Ctrl+C and then Ctrl+V in the editor🙂
— Tomas Petricek (@tomaspetricek) December 3, 2013
The truth is not so magical as on the face of it – just use the power of your file editor. Let’s repeat all steps once again to better remember:
- Find a place where you want to insert file path
- Press Ctrl+O that should open a standard file picker. By default VS should open a dialog in the directory where your current file is saved in.
- Start typing relative or absolute path to your file, BUT do not use mouse – you are able to use only auto-complete in file path edit box.
- When you find a file – select path to it (Ctrl+A)
- Copy it (Ctrl+C)
- Close file picker (Esc)
- Insert path in your script (Ctrl+V)
Do not type boring paths – do it like Tomas😉