- commit
- 024a4ba811ff60ed3dc34650ca619b536e5654c9
- parent
- 7f6b7e52337aadeb9a65a753cd9ec3841135257b
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2019-02-23 18:17
use s: and l: variables
Diffstat
| M | plugin/fets.vim | 49 | ++++++++++++++++++++++++------------------------- |
1 files changed, 24 insertions, 25 deletions
diff --git a/plugin/fets.vim b/plugin/fets.vim
@@ -26,53 +26,52 @@ 26 26 " 27 27 " [1]: http://nickgravgaard.com/elastic-tabstops/ 28 2829 -1 function! MaxTabCount()30 -1 let _max = 0-1 29 function! s:MaxTabCount() -1 30 let l:max = 0 31 3132 -1 for l in getline(0, "$")33 -1 let tab_count = len(split(l, '\t')) - 134 -1 if tab_count > _max35 -1 let _max = tab_count-1 32 for l:line in getline(0, "$") -1 33 let l:tab_count = len(split(l:line, '\t')) - 1 -1 34 if l:tab_count > l:max -1 35 let l:max = l:tab_count 36 36 endif 37 37 endfor 38 3839 -1 return _max-1 39 return l:max 40 40 endfunction 41 4142 -1 function! CalcTS()43 -1 let _max = 044 -1 let tab_count = MaxTabCount()45 -1 echom tab_count-1 42 function! s:CalcTS() -1 43 let l:max = 0 -1 44 let l:tab_count = s:MaxTabCount() 46 4547 -1 for l in getline(0, "$")48 -1 let i = 0-1 46 for l:line in getline(0, "$") -1 47 let l:i = 0 49 4850 -1 for item in split(l, '\t')[:-2]51 -1 if i < tab_count52 -1 if len(item) > _max53 -1 let _max = len(item)-1 49 for l:item in split(l:line, '\t')[:-2] -1 50 if l:i < l:tab_count -1 51 if len(l:item) > l:max -1 52 let l:max = len(l:item) 54 53 endif 55 5456 -1 let i += 1-1 55 let l:i += 1 57 56 endif 58 57 endfor 59 58 endfor 60 5961 -1 return _max + 1-1 60 return l:max + 1 62 61 endfunction 63 62 64 63 function! FETS()65 -1 let fets = CalcTS()-1 64 let l:fets = s:CalcTS() 66 6567 -1 if fets == &l:tabstop-1 66 if l:fets == &l:tabstop 68 67 let &l:tabstop = 2 69 68 let &l:softtabstop = 2 70 69 let &l:shiftwidth = 2 71 70 else72 -1 let &l:tabstop = fets73 -1 let &l:softtabstop = fets74 -1 let &l:shiftwidth = fets-1 71 let &l:tabstop = l:fets -1 72 let &l:softtabstop = l:fets -1 73 let &l:shiftwidth = l:fets 75 74 endif 76 75 endfunction 77 7678 -1 map <c-t> :call FETS()<cr>-1 77 map <c-t> :call FETS()<CR>