Vscode-code-runner: How can I specify a hotkey to run a currently opened file?

Created on 26 Jan 2017  路  13Comments  路  Source: formulahendry/vscode-code-runner

For example I have a python file opened. I want to press a hotkey and it would instantly run this python file.

If for example I had a go file opened. I press the same hotkey and it would run this go file.

Thank you for any help.

help wanted question

Most helpful comment

Hi @nikitavoloboev , the default hotkey is Ctrl+Alt+N. To change the hotkey, go to the menu under File > Preferences > Keyboard Shortcuts, and change the keyboard shortcut for code-runner.run. Refer to https://code.visualstudio.com/docs/customization/keybindings#_customizing-shortcuts

All 13 comments

Hi @nikitavoloboev , the default hotkey is Ctrl+Alt+N. To change the hotkey, go to the menu under File > Preferences > Keyboard Shortcuts, and change the keyboard shortcut for code-runner.run. Refer to https://code.visualstudio.com/docs/customization/keybindings#_customizing-shortcuts

Thank you, this works perfectly.

However there is an issue with running a go file :

2017-01-27 at 14 59

Could you please try go run /foo/bar/main.go in your terminal?

Running go run in the terminal on this file works well.

How is the path of GO in your environment variables? Is it Users/***/go? Seems it should be /Users/***/go

The path is set correctly I believe.

This is however a folder outside the go src folder. Perhaps that makes a difference?

May be the root cause (the cwd is different). Could you try below setting (to run code in terminal of VS Code) and run again?
Go to File > Preferences -> User Settings, and open settings.json, and set like below:

{
    "code-runner.runInTerminal": true
}

Ok, now it works when you run the code the first time. However if you run it again, it gets stuck and never finishes the second go run command for some reason :

2017-01-29 at 14 07

Could you please simplify you GO file and try again? e.g. just fmt.Println('hello')

Same thing :

2017-01-29 at 14 19

I have installed GO on my Mac. And it works on both terminal and non-terminal. I think this may not be related to this extension, since it is also working for JS in your environment.

It is really quite annoying. It go runs and gives the output for the first command. But it seems the second one gets run indefinitely and no result is shown.

I have to close the terminal and run again if I want to see output. :(

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Yensan picture Yensan  路  4Comments

mjaniec2013 picture mjaniec2013  路  5Comments

ranolfi picture ranolfi  路  3Comments

sstorey-nephila picture sstorey-nephila  路  5Comments

nmchgx picture nmchgx  路  3Comments