Hacker News new | comments | show | ask | jobs | submit login

You can get rid of the global variable by testing the actual settings instead:

    function! NumberToggle()
        if (!&number && !&relativenumber)
            set number
            set norelativenumber
        elseif (&number && !&relativenumber)
            set relativenumber
            set nonumber
            set norelativenumber
        set foldcolumn=0

Thanks! It was my first attempt writing a vim function, so wasn't exactly sure. This looks much better.

Applications are open for YC Winter 2018

Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact