初嘗 Vim 如「左手拿筷子」,全身使不上勁。實務建議:
核心需求:自動補全、括號匹配、錯誤檢查、整合 GDB 除錯——Vim 需大量配置(ctags、cscope)才能勉強達標,不如直接用現代化 IDE。
int main(int argc, char* argv[]) {
if (argc < 2) {
cout << "-no input! use 'comdel -h' for help" << endl;
return -1;
}
if (strcmp(argv[1], "--help") == 0 || strcmp(argv[1], "-h") == 0) {
cout << "Usage: comdel [options] [file [args]]" << endl;
cout << "Options:" << endl;
cout << " -h (--help): show help" << endl;
cout << " -kl: keep line as before" << endl;
cout << "Example: comdel -kl test0.h test1.c test2.cpp" << endl;
return 0;
}
StringList options;
for (int i = 1; i < argc; ++i) {
string str = argv[i];
if (str == "-kl") keep_line = 1;
else options.push_back(str);
}
for_each(options.begin(), options.end(), process);
return 0;
}
# CMakeLists.txt 基礎範本
cmake_minimum_required(VERSION 3.10)
project(MyProject LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 17)
add_executable(myapp main.cpp utils.cpp)
target_link_libraries(myapp pthread)
優點:跨平台、IDE 無縫整合、依賴管理清晰、支援外部套件尋找。
Windows 轉 Linux 不只是換作業系統,更是工程化思維升級:統一編碼規範、擁抱現代化 IDE 與建置系統、掌握 GDB 除錯技能。工具鏈順手,才能專注解決業務問題,而非與環境纏鬥。