3
我使用AppendModeline功能模式行添加到我的VIM文件:有没有办法在vim中获取布尔选项的字符串表示?
" Append modeline after last line in buffer. " Use substitute() instead of printf() to handle '%%s' modeline in LaTeX " files. function! AppendModeline() let l:modeline = printf(" vim: set ts=%d sw=%d tw=%d :", \ &tabstop, &shiftwidth, &textwidth) let l:modeline = substitute(&commentstring, "%s", l:modeline, "") call append(line("$"), l:modeline) endfunction
但我想扩展它。它应支持添加当前值expandtab。
使用& expandtab,我可以得到当前值的数字表示。但是像set et = 0不支持vim。它必须是设置[no] expandtab。
难道我真的要测试& expandtab和追加expandtab或noexpandtab到升:模式行还是有一种方式来获得当前值的字符串表示?
set expandtab?显示[no] expandtab,但我不知道如何在脚本中使用它(或者甚至可能)。