>F#: Refresh Project Templates
.classlib
template and hit Enter.ClassLibraryDemo
as the name. Once you've entered the name you want for your project, hit Enter.ClassLibraryDemo
folder.Paket
.FAKE
.paket.exe
executable that can fetch packages and resolve dependencies for you..gitignore
file if you wish to add this project to Git-based source control.ClassLibraryDemo.fs
, an F# implementation file with a class defined.ClassLibraryDemo.fsproj
, an F# project file used to build this project.Script.fsx
, an F# script file that loads the source file.paket.references
, a Paket file that specifies the project dependencies.Script.fsx
, and add the following code at the end of it:;;
. This is because FSI allows you to enter multiple lines. The ;;
at the end lets FSI know when the code is finished.toPigLatin
is a function that takes a word as its input and converts it to a Pig-Latin representation of that word. The rules for this are as follows:toPigLatin
is a function that takes in a string
as input (called word
), and returns another string
. This is known as the type signature of the function, a fundamental piece of F# that's key to understanding F# code. You'll also notice this if you hover over the function in Visual Studio Code.isVowel
, that determines if a given character (c
) is a vowel by checking if it matches one of the provided patterns via Pattern Matching:if..then..else
expression that checks if the first character is a vowel, and constructs a return value out of the input characters based on if the first character was a vowel or not:toPigLatin
is thus:if..then..else
is itself an expression, the body of the then
block or the body of the else
block will be returned depending on the input value.ClassLibraryDemo.fs
. You'll notice that some code is already in there. Go ahead and delete the class definition, but make sure to leave the namespace
declaration at the top.module
called PigLatin
and copy the toPigLatin
function into it as such:Script.fsx
file again, and delete the entire toPigLatin
function, but make sure to keep the following two lines in the file:open
the ClassLibraryDemo
namespace so that you have access to the functionality.PigLatin
module that you defined earlier:fsc
in a command line for the F# compiler, and fsi
or fsharpi
for the Visual F# tools on Windows and Mono on Mac/Linux, respectively.ionide-fsharp
directory on your machine and reinstall the plugin suite.Syntax Coloring | Some syntax elements of code and markup files are colored differently to distinguish them. For example, keywords (such as using in C# and Imports in Visual Basic) are one color, but types (such as Console and Uri ) are another color. Other syntax elements are also colorized, such as string literals and comments. C++ uses color to differentiate among types, enumerations, and macros, among other tokens.You can see the default color for each type, and you can change the color for any specific syntax element in the Fonts and Colors, Environment, Options dialog box, which you can open from the Tools menu. |
Error and Warning Marks | As you add code and build your solution, you may see (a) different-colored wavy underlines (known as squiggles) or (b) light bulbs appearing in your code. Red squiggles denote syntax errors, blue denotes compiler errors, green denotes warnings, and purple denotes other types of errors. Quick Actions suggest fixes for problems and make it easy to apply the fix. You can see the default color for each error and warning squiggle in the Tools > Options > Environment > Fonts and Colors dialog box. Look for Syntax Error, Compiler Error, Warning, and Other Error. |
Brace Matching | When the insertion point is placed on an open brace in a code file, both it and the closing brace are highlighted. This feature gives you immediate feedback on misplaced or missing braces. You can turn brace matching on or off with the Automatic Delimiter Highlighting setting (Tools > Options > Text Editor). You can change the highlight color in the Fonts and Colors setting (Tools > Options > Environment). Look for Brace Matching (Highlight) or Brace Matching (Rectangle). |
Structure Visualizer | Dotted lines connect matching braces in code files, making it easier to see opening and closing brace pairs. This can help you find code in your codebase more quickly. You can turn these lines on or off with the Show structure guidelines in the Display section of the Tools > Options > Text Editor > General page. |
Line Numbers | Line numbers can be displayed in the left margin of the code window. They are not displayed by default. You can turn this option on in the Text Editor All Languages settings (Tools > Options > Text Editor > All Languages). You can display line numbers for individual programming languages by changing the settings for those languages (Tools > Options > Text Editor > <language>). For line numbers to print, you must select Include line numbers in the Print dialog box. |
Change Tracking | The color of the left margin allows you to keep track of the changes you have made in a file. Changes you have made since the file was opened but not saved are denoted by a yellow bar on the left margin (known as the selection margin). After you have saved the changes (but before closing the file), the bar turns green. If you undo a change after you have saved the file, the bar turns orange. To turn this feature off and on, change the Track changes option in the Text Editor settings (Tools > Options > Text Editor). |
Selecting Code and Text | You can select text either in the standard continuous stream mode or in box mode, in which you select a rectangular portion of text instead of a set of lines. To make a selection in box mode, press Alt as you drag the mouse over the selection (or press Alt+Shift+<arrow key>). The selection includes all of the characters within the rectangle defined by the first character and the last character in the selection. Anything typed or pasted into the selected area is inserted at the same point on each line. |
Zoom | You can zoom in or out in any code window by pressing and holding the Ctrl key and moving the scroll wheel on the mouse (or Ctrl+Shift+. to increase and Ctrl+Shift+, to decrease). You can also use the Zoom box in the lower left corner of the code window to set a specific zoom percentage. The zoom feature does not work in tool windows. |
Virtual Space | By default, lines in Visual Studio editors end after the last character, so that the Right Arrow key at the end of a line moves the cursor to the beginning of the next line. In some other editors a line does not end after the last character, and you can place your cursor anywhere on the line. You can enable virtual space in the editor in the Tools > Options > Text Editor > All Languages settings. Note that you can enable either Virtual Space or Word Wrap, but not both. |
Printing | You can use the options in the Print dialog box to include line numbers or hide collapsed regions of code when you print a file. In the Page Setup dialog box, you can also choose to print the full path and the name of the file by choosing Page header. You can set color printing options in the Tools > Options > Environment > Fonts and Colors dialog box. Choose Printer in the Show settings for list to customize color printing. You can specify different colors for printing a file than for editing a file. |
Global Undo and Redo | The Undo Last Global Action and Redo Last Global Action commands on the Edit menu undo or redo global actions that affect multiple files. Global actions include renaming a class or namespace, performing a find-and-replace operation across a solution, refactoring a database, or any other action that changes multiple files. You can apply the global undo and redo commands to actions in the current Visual Studio session, even after you close the solution in which an action was applied. |
Format Document | Sets the proper indentation of lines of code and moves curly braces to separate lines in the document. |
Format Selection | Sets the proper indentation of lines of code and moves curly braces to separate lines in the selection. |
Tabify Selected Lines | Changes leading spaces to tabs where appropriate. |
Untabify Selected Lines | Changes leading tabs to spaces. If you want to convert all the spaces in your file to tabs (or all the tabs to spaces), you can use the Edit.ConvertSpacesToTabs and Edit.ConvertTabsToSpaces commands. These commands do not appear in Visual Studio menus, but you can call them from the Quick Access window or the command window. |
Make Uppercase | Changes all characters in the selection to uppercase, or if there is no selection, changes the character at the insertion point to uppercase. Shortcut: Ctrl+Shift+U. |
Make Lowercase | Changes all characters in the selection to lowercase, or if there is no selection, changes the character at the insertion point to lowercase. Shortcut: Ctrl+U. |
Move selected Lines Up | Moves the selected line up one line. Shortcut: Alt+Up Arrow. |
Move Selected Lines Down | Moves the selected line down one line. Shortcut: Alt+Down Arrow. |
Delete Horizontal White Space | Deletes tabs or spaces at the end of the current line. Shortcut: Ctrl+K, Ctrl+ |
View White Space | Displays spaces as raised dots, and tabs as arrows. The end of a file is displayed as a rectangular glyph. If Tools > Options > Text Editor > All Languages > Word Wrap > Show visible glyphs for word wrap is selected, that glyph is also displayed. |
Word Wrap | Causes all the lines in a document to be visible in the code window. You can turn word wrap off and on in the Text Editor All Languages settings (Tools > Options > Text Editor > All Languages). |
Comment Selection | Adds comment characters to the selection or the current line. Shortcut: Ctrl+K, Ctrl+C |
Uncomment Selection | Removes comment characters from the selection or the current line. Shortcut: Ctrl+K, Ctrl+U |
Increase Line Indent | Adds a tab (or the equivalent spaces) to the selected lines or the current line. |
Decrease Line Indent | Removes a tab (or the equivalent spaces) from the selected lines or the current line. |
Select Tag | In a document that contains tags (for example, XML or HTML), selects the tag. |
Select Tag Content | In a document that contains tags (for example, XML or HTML), selects the content. |