ÔÚLinuxÉÏʹÓÃSublime Text¾ÙÐÐC/C++±à³ÌµÄÍƼöÉèÖÃ
ÔÚlinuxÉÏʹÓÃsublime text¾ÙÐÐc/c++±à³ÌµÄÍƼöÉèÖÃ
¼ò½é£º
Sublime TextÊÇÒ»¿îÇáÁ¿¼¶¡¢Ç¿Ê¢ÇҸ߶ȿɶ¨ÖƵÄÎı¾±à¼Æ÷¡£ÔÚLinuxƽ̨ÉÏ£¬Ê¹ÓÃSublime Text¾ÙÐÐC/C++±à³ÌÊÇÒ»ÖÖ³£ÓõÄÑ¡Ôñ¡£±¾ÎĽ«ÏÈÈÝһЩÍƼöµÄÉèÖúͲå¼þ£¬ÒÔ×ÊÖúÌá¸ß±à³ÌЧÂʺͿª·¢ÌåÑé¡£
×°ÖÃSublime Text£º
Ê×ÏÈ£¬ÄãÐèÒª´ÓSublime Text¹Ù·½ÍøÕ¾ÏÂÔØÊÊÓÃÓÚLinuxµÄ×°Öðü£¬²¢Æ¾Ö¤¹Ù·½Ö¸µ¼¾ÙÐÐ×°Öá£×°ÖÃÍê³Éºó£¬Äã¿ÉÒÔͨ¹ýÔÚÖÕ¶ËÖÐÊäÈësublÏÂÁîÀ´Æô¶¯Sublime Text¡£
ÉèÖñàÒëÇéÐΣº
ÔÚ×îÏȱàдC/C++´úÂë֮ǰ£¬ÄãÐèÒªÉèÖñàÒëÇéÐΡ£±¾ÎÄÒÔGCC±àÒëÆ÷ΪÀý£¬ÏÈÈÝÔõÑù¾ÙÐÐÉèÖá£Ê×ÏÈ£¬·¿ªSublime Text£¬Ôڲ˵¥À¸ÖÐÑ¡Ôñ”Tools”->”Build System”->”New Build System”¡£È»ºó£¬½«ÒÔÏ´úÂ븴ÖƵ½Ð½¨µÄÎļþÖУº
{ "shell_cmd": "gcc -std=c11 ${file} -o ${file_path}/${file_base_name} && ${file_path}/${file_base_name}", "target": "run", "selector": "source.c, source.cpp", "variants": [ { "name": "Run", "shell_cmd": "gcc -std=c11 -Wall -Wextra -pedantic -o ${file_path}/${file_base_name} ${file} && ${file_path}/${file_base_name}" }, { "name": "Debug", "shell_cmd": "gcc -std=c11 -g ${file} -o ${file_path}/${file_base_name} && gdb ${file_path}/${file_base_name}" } ] }
µÇ¼ºó¸´ÖÆ
ÉúÑÄÎļþ£¬²¢½«ÎļþÃûÃüÃûΪC.sublime-build¡£Õâ¸öÎļþ½ç˵Á˱àÒëºÍÔËÐеÄÏÂÁÄã¿ÉÒÔƾ֤ÐèÒª¾ÙÐÐ×Ô½ç˵¡£ÀýÈ磬Äã¿ÉÒÔÐÞ¸Ä-std=c11ΪÊÊÓÃÓÚÄãµÄ±àÒëÆ÷°æ±¾µÄ±ê×¼¡£×¢ÖØ£¬ÉÏÊöÉèÖý«ÔÚÉúÑÄÎļþµÄĿ¼ÏÂÌìÉú¿ÉÖ´ÐÐÎļþ£¬²¢Ê¹ÓÃÖÕ¶ËÔËÐС£
Á¬Ã¦Ñ§Ï°¡°C++Ãâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»
ÉèÖôúÂë×Ô¶¯²¹È«£º
Sublime TextÓи»ºñµÄ´úÂë×Ô¶¯²¹È«¹¦Ð§£¬¿ÉÒÔ´ó´óÌá¸ß±àд´úÂëµÄЧÂÊ¡£Äã¿ÉÒÔͨ¹ý×°ÖÃSublimeCodeIntel²å¼þÀ´ÊµÏÖ×Ô¶¯²¹È«¹¦Ð§¡£Ïêϸ°ì·¨ÈçÏ£º
·¿ªSublime Text£¬Ôڲ˵¥À¸ÖÐÑ¡Ôñ”Tools”->”Command Palette”£¬È»ºóÊäÈë¡°Package Control: Install Package¡±²¢°´»Ø³µ¼ü¡£
ÆÚ´ýƬÉκó£¬ÊäÈë¡°CodeIntel¡±²¢Ôٴΰ´»Ø³µ¼ü¡£Package Control»á×Ô¶¯ÏÂÔز¢×°Öòå¼þ¡£
×°ÖÃÍê³Éºó£¬ÖØÆôSublime Text¡£
ÉèÖôúÂëÃûÌû¯£º
´úÂëÃûÌû¯ÊÇÒ»¸öÖ÷ÒªµÄ¹¦Ð§£¬Ëü¿ÉÒÔʹ´úÂë¾ßÓÐͳһµÄÆøÑæÆøÑ棬Ò×ÓÚÔĶÁºÍά»¤¡£Äã¿ÉÒÔͨ¹ý×°ÖÃClangFormat²å¼þÀ´ÊµÏÖ´úÂëÃûÌû¯¹¦Ð§¡£ÒÔÏÂÊÇÏêϸµÄ²Ù×÷°ì·¨£º
·¿ªSublime Text£¬Ôڲ˵¥À¸ÖÐÑ¡Ôñ”Preferences”->”Package Control”->”Install Package”¡£
ÊäÈë¡°ClangFormat¡±²¢°´»Ø³µ¼ü¡£Package Control»á×Ô¶¯ÏÂÔز¢×°Öòå¼þ¡£
×°ÖÃÍê³Éºó£¬·¿ªÐèÒªÃûÌû¯µÄC/C++Îļþ£¬Ôڲ˵¥À¸ÖÐÑ¡Ôñ”Tools”->”ClangFormat”->”Format this file”¡£
ÆäËûÊÊÓòå¼þ£º
³ýÁËÉÏÊö²å¼þ£¬Sublime TextÉÐÓÐһЩÆäËûÊÊÓõIJå¼þ£¬¿ÉÒÔ×ÊÖúÄãÔ½·¢Àû±ãµØ¾ÙÐÐC/C++±à³Ì¡£ÒÔÏÂÊÇһЩÍƼöµÄ²å¼þ£º
BracketHighlighter£ºÓÃÓÚ¸ßÁÁÆ¥ÅäµÄÀ¨ºÅºÍ±êÇ©¡£
AutoFileName£º×Ô¶¯²¹È«Îļþ·¾¶¡£
GitGutter£ºÔÚ±à¼Æ÷ÖÐÏÔʾGitµÄÐ޸ġ¢Ìí¼ÓºÍɾ³ýÐÅÏ¢¡£
DocBlockr£º¿ìËÙÌìÉúº¯ÊýºÍÀàµÄÎĵµ×¢ÊÍ¡£
½áÓ
ͨ¹ýÒÔÉÏÉèÖúͲå¼þµÄʹÓã¬Äã¿ÉÒÔÔÚLinuxÉÏʹÓÃSublime Text¾ÙÐÐC/C++±à³Ì£¬²¢ÇÒÏíÊܵ½¸ßЧºÍÌñ¾²µÄ¿ª·¢ÌåÑé¡£ÎÞÂÛÊDZàÒëÇéÐεÄÉèÖá¢×Ô¶¯²¹È«µÄ¹¦Ð§ÕվɴúÂëÃûÌû¯£¬ÕâЩÉèÖúͲå¼þ¶¼½«´ó´óÌá¸ßÄãµÄ±à³ÌЧÂÊ¡£Ï£Íû±¾ÎÄÄܶÔÄãÓÐËù×ÊÖú£¡
ÒÔÉϾÍÊÇÔÚLinuxÉÏʹÓÃSublime Text¾ÙÐÐC/C++±à³ÌµÄÍƼöÉèÖõÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡