在 SecureCRT 中讓 Vim 顯示完整語法高亮,需同時配置終端機模擬設定與 Vim 運行配置。
選單:Options → Session Options → Terminal → Emulation
• Terminal 選 ANSI、Linux 或 xterm
• 勾選 ANSI Colour
~/.vimrc 核心配置" 基礎設定
set nocompatible
set ruler
set number
set autoindent
set smartindent
set shiftwidth=4
set tabstop=4
set noexpandtab
set wrap
set hlsearch
" 語法高亮與折疊
syntax on
set foldmethod=syntax
" GUI/終端機差異化配色
if has("gui_running")
set nowrap
set guioptions+=b
colorscheme inkpot
else
set wrap
colorscheme ron
" 終端機 256 色支援 (SecureCRT 需)
set t_Co=256
set t_Sf=^[[3%p1%dm
set t_Sb=^[[4%p1%dm
endif
" Leader 鍵設為逗號
let mapleader = ","
關鍵說明:
^[[ 為 Ctrl+V 後按 Esc 輸入的實際轉義字元t_Co=256 啟用 256 色模式,配合 t_Sf/t_Sb 讓 Vim 正確發送 ANSI 色碼套用後重新開啟 Vim 即可看到完整語法高亮與代碼折疊效果。