Tab Vs Space preferences in Vim

前端 未结 7 1053
眼角桃花
眼角桃花 2020-12-07 07:31

Vim is very accommodating when it comes to tab Vs. space preferences. As I understand it, the tabstop setting indicates the width of a tab character. The

7条回答
  •  粉色の甜心
    2020-12-07 07:43

    This is my first attempt at writing VimScript, but here goes:

    function! Stab(value)
        let &shiftwidth  = a:value
        let &softtabstop = a:value
        let &tabstop     = a:value
    endfunc
    

    If I put this in my .vimrc file, I can call it by running :call Stab(X), where X is the desired tab width. This is an adequate solution for now, but if anyone can suggest a way of making it easier to call I would be grateful.

    I've also created a function that quickly summarizes the current settings, which I have mapped to ctrl-Tab:

    nmap  :call TabParams()
    function! TabParams()
        echo "tabstop:     ".&tabstop
        echo "shiftwidth:  ".&shiftwidth
        echo "softtabstop: ".&softtabstop
    endfunc
    

    Well, I put up a 100 point bounty for this answer, and now I've half solved it myself. Not sure if I can accept my own answer...

提交回复
热议问题