Question

I have 2 small plugins on Vim. One plugin for increase/decrease the font in Vim (suitable when I work on different screens).

One plugin to get full screen in Vim (I'm working in Gvim), so without window borders, task bar, etc. Okay. When I zoom in or zoom out of the font, I get the weird borders. I toggle fullscreen off, then toggle it back and everything looks fine again.

This is my key mapping for toggling the zoom function and full screen function

noremap ' :ZoomIn<CR> 
noremap - :ZoomOut<CR> 

Then this is my mapping for toggling the fullscreen.

map <A-1> :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR> 

When I'm zooming in or zooming out, I need to toggle the fullscreen off and toggle on, to get rid of the weird borders. I thought it would be useful to give multiple commands in one key. So I mapped this:

noremap ' :ZoomIn |:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0) |:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>

When i press the key ', I get the warning that there are trailing characters.

I looked into :help :bar and it seems that I need to use because this would disable the trailing characters. So I did.

noremap ' :ZoomIn <bar>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0) <bar>:call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>

Same message again, trailing characters. Okay, then I tried another way.

function ToggleZoom()
     :ZoomIn<CR> 
     :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
     :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
endfunction
noremap ' :ToggleZoom()<CR>

This solution failed too, get the warning of trailing characters. Even I couldn't find any trailing characters here. Have anyone suggestions? I would appreciate it!

Was it helpful?

Solution

For the last one

function ToggleZoom()
     :ZoomIn<CR> 
     :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
     :call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)<CR>
endfunction
noremap ' :ToggleZoom()<CR>

You don't need the : Or the <CR> inside the function. To call the function in a mapping you would use call since ToggleZoom() is a function not a command.

function ToggleZoom()
     ZoomIn
     call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)
     call libcallnr("gvimfullscreen.dll", "ToggleFullScreen", 0)
endfunction
noremap ' :call ToggleZoom()<CR>

The reason ZoomIn does not allow | between commands is the command probably isn't declared with the -bar argument. Take a look at :h command-bar

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top