January 2015
Beginner to intermediate
85 pages
1h 58m
English
At this point you probably won’t be shocked to learn how we define our own commands: by using a command! Specifically, we use :command to define commands. (Hmm—that certainly sounds redundant.)
User commands, like user functions, have to start with uppercase letters. And what’s funny about user commands is that their job is simply to call built-in commands. If we want to define a command that calls a function—as we will be doing—we execute the :call command. Consider an example:
| mappings/command.vim | |
| | function! EchoQuote() |
| | echo 'A poet can but ill spare time for prose.' |
| | endfunction |
| | command Quote call EchoQuote() |
This defines a user command called :Quote. Just like with :command itself, we can leave the colon ...
Read now
Unlock full access