Skip to content

Latest commit

 

History

History
52 lines (39 loc) · 2.05 KB

EditorForVisualStudio.md

File metadata and controls

52 lines (39 loc) · 2.05 KB

NTypewriter editor for Visual Studio

Getting started

  1. Install NTypewriter editor for Visual Studio
  2. Add template file with *.nt extension to your project
  3. You gain access to code model from your template by special global variable data. So let us iterate over every class defined in solution, and write its name to output.
{{ for class in data.Classes 
     class.FullName | String.Append "\r\n"
  end }}  
  1. Now it is time to decide what part of our template will be saved to a file. We do that by using capture statement capture variableName; end. For this example we want to generate one file with list of all classes defined in solution, thus we should use capture statement outside of the for loop.
{{ capture output
       for class in data.Classes 
             class.FullName | String.Append "\r\n"
       end 
   end}}
  1. To create file on disk we use Save whatToSave filePath function
{{ capture output
       for class in data.Classes 
           class.FullName | String.Append "\r\n"
      end
   end
   Save output "index.txt"
}}    
  1. We have completed template, now we can run it and generate file.

NTypewriter CodeModel

  1. If something goes wrong you can look at NTypewriter output. NTypewriter is very chatty about what is doing at the moment. Most of the errors also will appear on the VS Error List.

Configuration

Options are available here:

Visual Studio :: Main menu -> Tools -> Options -> NTypeWriter -> General

Live preview

General -> Preview -> IsEnabled

Preview when enabled may slow down your VS significantly.

Note Preview requires Microsoft Edge WebView2 to be installed on the machine.