Ad blocker interference detected!
Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers
Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.
Should use &shiftwidthEdit
Rather than passing shiftwidth as a parameter to the function, I suggest reading the value of the Vim option directly. That way, if the user has different shiftwidths for different file types, this can continue to work transparently.
" clever tabs (tabs only on the line beginning) function! CleverTabs() let line = getline('.')[:col('.')-2] if col('.') == 1 || line =~ '^\t*$' || line =~ '^$' let z = "\t" else let space = "" let shiftwidth = shiftwidth() let shiftwidth = shiftwidth - ((virtcol('.')-1) % shiftwidth) while shiftwidth > 0 let shiftwidth = shiftwidth - 1 let space = space . ' ' endwhile let z = space endif return z endfunction "CleverTabs " map tab key to function imap <silent> <Tab> <C-r>=CleverTabs()<cr>
--October 9, 2014
I changed your function to use the shiftwidth() function instead of the option, since it changed recently to use 0 as a flag to use tabstop instead. --Fritzophrenic (talk) 16:10, October 10, 2014 (UTC)