Sublime Text build and run - build

Notepad++ has a "Run" feature where you can simply run "$(full_current_path)" and it will run the file you're working on with its default program.
Is there any way Sublime Text can do this as well?

In ST2, you can set its build system in: Tools > Build System > New Build System
And here you can find the manual https://www.sublimetext.com/docs/3/build_systems.html

Related

File not formatting after saving in Sublime even when SublimeAstyleformatter's autoformat_on_save is true

So I tried setting up Sublime text editor for programming in cpp on mac , and to use formatter I added the sublimeAstyleformatter plugin and then followed these steps:
Sublime Text > Preferences > Browse packages > SublimeAstyleformatter > SublimeAStyleFormatter.sublime-settings
and inside the file I changed the autoformat_on_save to true and saved the file, but still whenver I save the cpp code, the file is not formatted.
I searched but didn't find any way out, Any help would be appreciated
I understand many windows users are facing the same issue on their systems too. It's probably because you may have installed fresh OS on your system.
so let's get to the solving part.
I am assuming if you are reading this answer you're already done with this step:
Preferences > Browse Packages > SublimeAStyleFormatter > SublimeAStyleFormatter.sublime-settings > "autoformat_on_save": true, (change false to true in line 8)
(If not then do the above step after installing AsytleFormatter package in sublime, and give it a go-to check whether it started working or not)
Now, after this, if your formatter still doesn't work there is a major chance your system doesn't have Microsoft Visual C++ 2010 x64 Redistributable - 10.040219
here is the official link : Microsoft Visual C++ 2010 x64 Redistributable-10.040219
install this software, relaunch sublime editor and you are good to go.
PS: For confirmation do the following (I have added snap for reference Screenshot):
Right-click in the file on your sublime editor
Hover over AStyleFormatter
Now you will be able to see the "format" option (which previously was greyed out)
( Hope it helps to solve the issue!)
I was facing issue with my m1 mac. Now it is resolved. What I did was open sublime text using Rosetta. Some of the sublime packages started working for me as I changed sublime text to open using Rosetta, when I click.
Follow these steps.
Quit Sublime text.
Go to Applications.
Right click on Sublime Text -> Get Info -> Select "Open using Rosetta" checkbox.
Open sublime Text again and check.
This resolved the issue for me. However, in case you do not want to go through Rosetta for sublime, then you can have Clang format Sublime Package installed; that works natively, without going through Rosetta.
Going off the documentation, the key combos on macOS/OSX are CtrlAltF for format current file and ⌘K, ⌘F for format current selection (you had it backwards). The Command Palette commands are called SublimeAStyleFormatter: Format Current File and SublimeAStyleFormatter Format Current Selection.
After looking through the issues on the plugin's Github repo, it looks like the Microsoft Visual C++ 2010 SP1 Redistributable Package (x64) is required for the plugin to work. However, seeing as you're on macOS, I'm not sure what else would be required.

How do I open WebStorm from terminal?

I've looked around but I've only found answers for past versions. I have a new version of WebStorm and I want to open my projects from the command line, but wstorm . and webstorm . doesn't seem to work.
I've tried going to Tools > Create Command Line Launcher... and I get this:
I go to ToolBox's WebStorm Settings and I'm met with this:
Generate shell scripts is turned on, but the but the commands still do not work in my terminal.
Am I missing something? Am I supposed to add in a Shell scripts location? I'm not entirely sure I understand.
It's actually very easy. First you open up Webstorm, and press SHIFT twice. This will bring up a search box, where you type: Create Command Line Launcher. You will see a search result from Tools will be highlighted, click on it, and it will suggest the default path. Just click on Ok. Your command line launcher is now ready, so you can open terminal, cd to your project root folder, and type webstorm ./ to launch webstorm.
If the Create Command Line Launcher option is not working, try the following:
If you are on MacOS, try adding the path as instructed in their official page. And if you are on Linux, just uninstall the current version and reinstall as a snap package using sudo snap install webstorm --classic. This way, you can launch it from the terminal just by typing webstorm
After opening a ticket with Jetbrains support, the default path is /usr/local/bin. Adding this worked.
You can use open-ide tool. It allows you to define all of your editors and to open any folder with your editor straight from terminal

Can we run commands in terminal directly from scite editor?

I just started using Scite Text editor.
Is it possible to change our directory location and run the commands in terminal directly from scite ?
Is there any other text editor for c/c++ which can support this ?

How to run “:compiler msvc” and “:comp msbuild” with Vim on Windows?

I have VS Express (2012) for Desktop. Am I also acquired the NMAKE.EXE program?
http://msdn.microsoft.com/en-us/library/dd9y37ha.aspx - The Microsoft
Program Maintenance Utility (NMAKE.EXE) is a tool that builds projects
based on commands contained in a description file.
When I run :make after running :compiler msvc, the shell returned the message “'nmake' is not recognized as an internal or external command,”. How can I compile a C++ program using these commands? Does the tool NMAKE.EXE have a relation to the 'nmake' command?
http://msdn.microsoft.com/en-us/library/wea2sca5(v=vs.90).aspx -
MSBuild is the new build platform for Microsoft and Visual Studio.
http://msdn.microsoft.com/en-us/library/dd293626.aspx - You can use
the MSBuild tool to build a Visual C++ application from the
command prompt. The build process is controlled by the information in
a project file (.vcxproj) that you can create and edit. The project
file specifies build options based on build stages, conditions, and
events.
Did I also acquired the MSBuild tool because of my VS Express for Desktop? When I use :make after running :compiler msbuild, the shell returned the message “'msbuild' is not recognized as an internal or external command,”. Does msbuild.vim have a relation to MSBuild tool?
The maintainer of msbuild.vim said, “I made the script for compiling
C# projects using .NET... I don't know if it will work for C++...”
How can I be able to compile by running :compiler msbuild before :make in Vim?
There are only two questions about compiling a program such as a C++ source file, on this question, and please answer with detailed instructions:
How to use :compiler msvc?
How to use :compiler msbuild?
When I use :make after running :compiler msbuild, the shell returned
the message “'msbuild' is not recognized as an internal or external
command,”.
Does msbuild.vim have a relation to MSBuild tool?
Yes.
To enable msbuild in Command Prompt, you simply have to add the path to the .net4 framework install on your machine to the PATH environment variable.
The following worked for me on Windows:
You can access the environment variables by right clicking on 'Computer', click 'properties' and click 'Advanced system settings' on the left navigation bar. On the next dialog bog click 'Environment variables,' scroll down to 'PATH' and edit it to include your path to the framework (don't forget a ';' after the last entry in here.
For reference my path was C:\Windows\Microsoft.NET\Framework64\v4.0.30319. [1]
Though I only use it for C# projects, I suppose it will work for C++ as well.
Remember that you have to run msbuild inside the project directory, otherwise msbuild will not be able to find your project.
For the sake of completeness, here a snippet of my vimrc (which the OP already got by email).
noremap <F4> :<C-U>silent make<CR>:redraw!<CR>
au FileType cs compiler msbuild
Patches and additions to this compiler script are always welcome, of course!
Regards
[1]: How do I run msbuild from the command line using Windows SDK 7.1?
A quick search came across this: Getting started - C/C++ programming with VIM, which may be a good starting point.
As user786653 mentioned, this is failing because your PATH doesn't include the directory nmake.exe is in. You can inspect your path with
:echo $PATH
Vim doesn't replace the underlying build functionality, it simply wraps it.
Start gVim from the Visual Studio command prompt
Create new files in a test directory:
test.cpp
#include <iostream>
int main() {
printf("hello world.");
return 0;
}
Makefile
all:
cl test.cpp
set the compiler (gVim)
:compiler msvc
compile (gVim)
:make
I don't have the msbuild.vim script, but by setting the "make program" to msbuild.exe
:set makeprg=msbuild
you can build, by running :make from a directory containing a solution (.sln) or project (.vxcproj) file, or you can use the msbuild.exe command line like this:
:make c:\Test\Test.sln /t:Rebuild /p:Configuration=Debug
After compiling, you can examine the output with
:copen
and navigate the errors with (n for next, p for previous, and r for rewind to the first error)
:cn
:cp
:cr

Build systems in Sublime Text

I'm just beginning to learn programming (on C++ and Python), and by beginning I mean total beginning ("hello world" beginning...). Not wanting to use multiple IDE's, I would like to be able to code and build–simple–programs with my text editor, Sublime Text 2. Could someone indicate me, with a step-by-step tutorial, how to implement C++ and Python compiling and executing capabilities in Sublime Text.
I've searched Sublime Text build systems on the site, but the answers are very specific and can't help a rookie like me (but they'll probably help me later).
Thanks
Sublime Text 2 already comes with scripts for building and running Python and C++ programs.
Simply press Cmd+B (or Ctrl+B on Windows & Linux) when a .py or .cpp file is open. The Python file will automatically execute and show the result in the built in console.
For C++, you need to press Cmd+Shift+B (Ctrl+Shift+B on Windows & Linux) to run it after building.
You need to have Python installed (get it here for Windows), and also a C++ compiler. The build system for C++ tries to call g++ by default (get it here for Windows. Remember to select the C++ compiler when installing!).
You will need to add the directories to path (c:\python32\ or similar for python, c:\mingw\bin or similar for the C++ compiler).
On windows, you may experience problems running the C++ programs (it tries to use bash). But Ctrl+B builds the program, and you can then use a command line to run it. Python works flawlessly on Windows.
windows(install minigw, python2.7 and added to the system path)
cpp:
build: ctrl+b
run: ctrl+shift+b
python:
build and run: ctrl+b
you may try to learn the the .sublime-build files in your Tools -> Build system -> New build system
So, you don't want to use an IDE but then you want IDE features from a text editor? :)
Most people who use a text editor for writing code use terminal to build and run the code.
So, for C++, the instructions are:
make (or gcc myprogram.c)
./myprogram
for a Python program, it's even simpler:
python ./myprogram.py
If you're not comfortable with terminal, then you probably need an IDE.
for c++ I actually made sublime to produce colorful error messages which are easier to read and you can also click on the errors which takes you to the file with the error.
You can look at how I modified the build to do what I wanted in here