Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

In vim, how do I define a function that can be called without :call?

Tags:

function

vim

How do I define a function so that I can call it from command-line mode without :call in front of it?

Right now, I have to do this: :call TrimWhitespace()

I want to define it so that I can do this: :TrimWhitespace

like image 869
kenny Avatar asked Sep 15 '11 16:09

kenny


1 Answers

This won't be a function, you should create a command instead. Check the documentation for commands (:help user-commands in Vim).

The simplest case is of a command to call a function:

command! TrimWhitespace call TrimWhitespace()
like image 114
sidyll Avatar answered Oct 06 '22 01:10

sidyll