📜  vim 获取光标处的颜色名称 - Shell-Bash 代码示例

📅  最后修改于: 2022-03-11 14:49:46.946000             🧑  作者: Mango

代码示例1
# Returns the foreground color ID of the character at cursor. 
# Replace "fg" with "bg" to get the background color.

:echo synIDattr(synIDtrans(synID(line("."), col("."), 1)), "fg")

#============================== SIDE-NOTE ===============================
# You can "alias" it in your vimrc for simpler use in the future like so:

cnoreabbrev GetFgColor echo synIDattr(synIDtrans(synID(line("."), 
        \ col("."), 1)), "fg")