Skip to content

Latest commit

 

History

History
78 lines (48 loc) · 2.72 KB

hello-world.md

File metadata and controls

78 lines (48 loc) · 2.72 KB

Tutorial

Hello World

Opening a Workspace

code-d works best when folders are opened.

For a simple project open a normal folder using the Open Folder... button.

It's possible to add multiple folders to the workspace in VSCode using File -> Add Folder to Workspace....

Click File -> Open Folder... or Ctrl-Shift-P -> Open Folder... to open an empty folder as workspace for your project.

example video

Working without workspace

It is also possible to have projects with very few files and no dependencies whatsoever. For this you can also open a workspace as described above to have full feature access (such as build tasks and dependencies) but for quickly editing singular D files it is also possible to simply open them in VSCode. However auto completion is limited to only the standard library in this case, so it's not a good idea to work like this for bigger projects.

Generating a Project using a Template

code-d contains project templates to quick-start the creation of projects.

Open an empty folder with the desired name for the project.

Continue by opening the command palette (F1 or Ctrl-Shift-P) and run code-d: Create new project. Follow the wizard to create the project.

example video

Writing code

You can now start coding away. To make this hello world project actually work, insert the following code:

import std.stdio;

void main()
{
	writeln("Hello World");
}

Things to note

The example projects create a DUB project for you. (Noticable with the dub.json or dub.sdl file which is present at root level)

This means you have access to the whole D package registry and can use DUB as build tool too.

See DUB homepage for more information.

Next Steps

Next you might want to check out the chapter Building to see how you can now run your application.

However if you don't want to use DUB for building and dependencies, check out how to configure non-DUB projects

You might also want to explore the Editor Features code-d has to offer.