key-bindings – ¿Cómo hacer zoom al texto en VIM a través de un acceso directo?

Pregunta:

Quiero hacer zoom en VIM, como texto Sublime o Atom, usando CTRL + & CTRL - y CTRL 0 para restablecer el tamaño de fuente predeterminado.

Respuesta:

Si está usando vim en una terminal, simplemente puede usar sus atajos de zoom. Para Gnome-Terminal, esto es Ctrl + + . En otros, puede ser Ctrl + Shift + + .

También existen varios complementos para este propósito. ej .: https://github.com/drmikehenry/vim-fontsize

Como alternativa, puede definir sus propias funciones como esta de vim.wika.com

let s:pattern = '^\(.* \)\([1-9][0-9]*\)$'
let s:minfontsize = 6
let s:maxfontsize = 16
function! AdjustFontSize(amount)
  if has("gui_gtk2") && has("gui_running")
    let fontname = substitute(&guifont, s:pattern, '\1', '')
    let cursize = substitute(&guifont, s:pattern, '\2', '')
    let newsize = cursize + a:amount
    if (newsize >= s:minfontsize) && (newsize <= s:maxfontsize)
      let newfont = fontname . newsize
      let &guifont = newfont
    endif
  else
    echoerr "You need to run the GTK2 version of Vim to use this function."
  endif
endfunction

function! LargerFont()
  call AdjustFontSize(1)
endfunction
command! LargerFont call LargerFont()

function! SmallerFont()
  call AdjustFontSize(-1)
endfunction
command! SmallerFont call SmallerFont()

A continuación, :LargerFont dos claves a :LargerFont y :SmallerFont

Leave a Comment

Your email address will not be published. Required fields are marked *

web tasarım