vim - Automatic window resizing -
vim - Automatic window resizing -
i'm trying write simple function in vim if buffer has little number of lines, after special key-pressing window fit whole buffer. here think
" total lines of current buffer function! <sid>totallines() allow n = 0 line in getline(1,'$') allow n+=1 endfor homecoming n endfunction " resize window function! <sid>resizecurrentwindow() if has("gui_running") allow linesnumber = <sid>totallines() if linesnumber < (&lines / 2) execute ':resize linesnumber' endif endif endfunction nnoremap <silent> <leader>rs :call <sid>resizecurrentwindow()<cr> well, resizecurrentwindow() function doesn't work: obtain 1-line-height window. if write
execute 'echo linesnumber' function works , output right result. suggestion? there fastest solution? thanks
try:
execute ':resize ' . linesnumber linesnumber variable , substituted value in above line. . string concatentation operator, adding string ':resize' , value of linesnumber produce total command want execute.
in code, "linesnumber" string literal passed straight argument resize command.
vim macvim
Comments
Post a Comment