My Stata editor: NotePad++

This post is part of an updated version of the chapters of the third part of the handbook Poverty and inequality measures in practice (2014) internally avaialable at the World Bank intranet.

Even though Stata has improved its do-file editor in version 13, it is still not a great tool for programming efficiently. Instead, we recommend using NotePad ++ (NP++). This is an excellent program that provides many useful features for writing Stata code quickly and easily. In this post, I provide you with all the necessary information to install NP++ and give you some tips on how to use it efficiently.


  1. Go to and install the latest version.
  • Make sure the box “don’t use App Data” is unchecked
  • (Optional but recommended) In case you require admin rights to install plugins, ask IT to install the plugins below. In order to install plugins you need to go to upper menu and click on plugins–> Plugins Admin, Then you just pick the plugins and click install.
Code Alignment
Indent by Fold
  1. Once you have installed NP++ in your computer, go to Friedrich Huebler’s webpage and download the zip files and provided at the top of the page.

  2. Extract the content of the zip files in the directory “C:/ado/personal”

  3. In Huebler’s page, scroll down to part 3 “Installation” and follow the three steps. Remember:

  • You do not need to go further than part “3” in the installation process
  • Step 3 suggests getting a syntax-highlighting tool for Stata on NotePad++ wiki. You could use the Stata syntax highlighter suggested in Houbler’s page, or you can use mine. I provide below the instructions on how to get my syntax highlighter.
  1. Follow items 1 and 2 in step 3. If you want to use the same shortcuts as the Stata editor, you can use Ctrl+D and Ctrl+Shift+D shortcuts for running do-file lines or entire do-files, respectively. However, keep in mind that shortcuts that use combinations with the Shift or the Ctrl keys might result in a “stuck” Shift or Ctrl key, and thus, your computer will be working as if you had the Ctrl or Shift keys pressed. To avoid this, you can use other combination of keyboard shortcuts. I use, for example, F9 and F10 as suggested by Huebler.

Getting a nice syntax highlighting

I do not like the Stata syntax highlighting suggested by Huebler, so based on the color palette Solarized created by Ethan Schoonover, I developed my own. You may find it my GitHub repository. Basically, this what you need to do.

  1. Run in Stata the following lines (you can do it using the Stata do-file editor. Probably, this will be the last time you’ll use it!). Make sure to modify the directory of the first local and also make sure that, after modifying the directory path, the folder exists. It might be the case that the AppData/Roaming/Notepad++ directory is not under the users directory, so you would have to find it. Keep in mind that the AppData directory is generally hidden so, even though you can’t see in the windows explorer, you can access it by providing the full directory path. In order to see hidden directories, I recommend using a file management tool like Total Commander.
local dir    "c:/Users/(USERNAME)/AppData/Roaming/Notepad++" // modify this
local source ""

local files "shortcuts.xml stylers.xml userDefineLang.xml"
foreach file of local files {
  copy "`source'/`file'" "`dir'/`file'", replace
  1. Restart NP++

  2. That’s it. Your new Stata syntax highlighting should look something like this:

Creating new do-files

To start a new do-file from scratch using NP++, you need to click on the Language tab and then click Stata. Otherwise, it will look like a plain text file. The first time you save your file, make sure you add the extension .do or .ado. Otherwise, NP++ does not know you are creating a do-file and, by default, it will save your file as a text file. It does not matter whether you are using the Stata syntax highlight, NP++ will not know that it is a do-file unless you save your file as such.

However, you should not have the need to start a new do-file of ado-file from scratch if you use the command dotemplate available in SSC. Also, you can see the development version in my GitHub repository and read my post A nice way to organize your do-files: dotemplate.

To set up your computer to read do-files on NP++ by default, open a Windows Explorer window and go to a directory that contains any do-file. Right Click on any do-file and click Open with –> Choose Default program. If NP++ is not listed in the Recommended Programs section, click Browse and look for NP++, which is usually placed in C:/Program Files/Notepad++. Finally, open the executable file notepad++.exe and check the box Always use the selected program to open this kind of file. From now on, your computer will always open your do-files using NP++. You might need to repeat the same procedure to open .ado, .hlp, and .shlp files

General tips

  • To quickly convert a line (or several lines) into a comment, place the cursor on the desired line (section) and press Ctrl+Q. Press Ctrl+Q again to uncomment.
  • Comment several lines with the general comment style (/* */) by pressing Ctrl+Shift+Q. Because of nesting comments, you cannot revert the commented section by pressing Ctrl+Shift+Q again. You would have to do it manually.
  • Convert text into upper case or lower case letters by selecting the words you want to convert and press Ctrl+Shift+U and Ctrl+U, respectively.
  • To edit several lines at the same time, just place the cursor where you need it and press the Alt+Shift+Arrow key to be in ‘column mode’ edition. You can then copy text or code from another source, select the lines you want in ‘column mode’ and paste the entire text of the code.
  • All loops or sections opened with { and closed with } can be collapsed or hidden as you wish by clicking the + sign within the square at the left side of the starting code-line.
  • If you want to know about more features of NP++, visit the official help manual.

R.Andres Castañeda, ed. 2014. Poverty and Inequality Measures in Practice: A Basic Reference Guide with Stata Examples. Washington, D.C.: World Bank.

Economist/Data Scientist

My research interests include … matter.