1

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!

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

2 Comments

Your solution worked for me! Many thanks. But I don't understand it. You tell that you to call the function in a mapping, you would use call. But ToggleZoom() is a function, but I see you don't call ZoomIn whithin the function?
@ReneFrogertjuh, it's the first line in the function.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.