Change quickly indentation size

2 Points

KabbAmine KabbAmine

9 years ago

A simple function that allow to change indentation size. Use :Indent.

command! Indent :call Indent()
function! Indent()
    let s:size_of_indentation = input("New indentation (".&ts.",".&sts.",".&sw.") => ")
    if(s:size_of_indentation != '')
        execute "setlocal ts=".s:size_of_indentation.""
        execute "setlocal sts=".s:size_of_indentation.""
        execute "setlocal sw=".s:size_of_indentation.""
    endif
endfunction

Martínez Ortiz Saúl Axel

Martínez Ortiz Saúl Axel 5 years ago

This is my version that also reindents the file:

function! Indent(spaces) let &tabstop = a:spaces let &shiftwidth = a:spaces let &softtabstop = a:spaces execute "normal! gg=G\<C-o>\<C-o>" endfunction