maverick_xiii's blog

By maverick_xiii, 11 years ago, In English

Since the Sublime text 3 build 3083 update, short-cuts for building and running single file C++ programs have changed. If you loved the old shortcuts (cmd+b to compile and cmd+shift+b to run), you can restore them by adding these custom key bindings.

	{
		"keys": ["super+b"], 
		"command": "build",
		"context": [
			{ "key": "selector", "operator": "equal", "operand": "source.c++" }
		], 
		"args": {
			"build_system": "Packages/C++/C++.sublime-build",
			"variant": "Build"
		}
	},
 
	{
		"keys": ["super+shift+b"], 
		"command": "build",
		"context": [
			{ "key": "selector", "operator": "equal", "operand": "source.c++" }
		],
		"args": {
			"build_system": "Packages/C++/C++.sublime-build",
			"variant": "Run"
		}
	},

	{
		"keys": ["super+b"], 
		"command": "build",
		"context": [
			{ "key": "selector", "operator": "equal", "operand": "source.java" }
		], 
		"args": {
			"build_system": "Packages/Java/Java.sublime-build",
			"variant": "Build"
		}
	},
 
	{
		"keys": ["super+shift+b"], 
		"command": "build",
		"context": [
			{ "key": "selector", "operator": "equal", "operand": "source.java" }
		],
		"args": {
			"build_system": "Packages/Java/Java.sublime-build",
			"variant": "Run"
		}
	}

Hope this helps :)

EDIT: The previous script I mentioned had a bug : The short-cut keys were executing c++ build command even for java source code. I have resolved that bug using 'context'. 'context' helps link multiple build_systems / commands with same short-cuts. So this should do the trick. And any undefined build_systems here would be executing default behaviour for the short-cuts :)

  • Vote: I like it
  • +14
  • Vote: I do not like it

| Write comment?
»
11 years ago, hide # |
 
Vote: I like it 0 Vote: I do not like it

Well can you help me to solve my problem of running C++ in Sublime text 2? It shows an error of this kind. g++: fatal error: -fuse-linker-plugin, but liblto_plugin-0.dll not found compilation terminated.

I downloaded MinGW and then added the bin address to the environment variables in advanced system settings in Windows 8.1.. Can you help??

»
10 years ago, hide # |
 
Vote: I like it +5 Vote: I do not like it

how and where to enter input?

  • »
    »
    10 years ago, hide # ^ |
     
    Vote: I like it 0 Vote: I do not like it

    You can add a command to run your compiled program from XTerm, or whatever terminal depending on your OS

»
8 years ago, hide # |
 
Vote: I like it -10 Vote: I do not like it

Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) [Finished in 0.1s with exit code 1] [cmd: ['g++', '-std=c++0x', '/Users/OptiMaze/Documents/ut.cpp', '-o', '/Users/OptiMaze/Documents/ut']] [dir: /Users/OptiMaze/Documents] [path: /Library/Frameworks/Python.framework/Versions/3.6/bin:/Users/OptiMaze/anaconda3/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin]

i am getting this message while running my c++ code. Can anyone help me with this?

»
6 years ago, hide # |
 
Vote: I like it +3 Vote: I do not like it

How to comment a block of C++ code in sublime text 3?