I was recently going through a tutorial on configuring the Vimrc file to make it behave more like traditional text editors. In that tutorial, I came across the following line: command! -nargs=* Wrap set wrap linebreak nolist
. This has the effect of allowing one to simply type ":Wrap" and activate a number of behaviors.
The problem I have is two-fold. First: is there an easy way to disable these settings (after they have been enabled) with a simple command or do I need to enter something like ":set nowrap nolinebreak list"
? Second, how does that "command!...." work? The tutorial gave no guidance as to how to interpret the mechanics of that line. What does "command!" do? What about "-nargs=*"? I understand everything else methinks... I am still too new to this to find simply reading the documentation to be particularly elucidating and have yet to find a tutorial on the subject.
:h :command
? The doc on this subject is quite straightforward. – Luc Hermitte Oct 2 '17 at 23:58:command
it permits you to source the file where the command is defined multiple times.-bang
permits to define banged commands -- and it's up to you to decide what to do with it.-nargs
shall be read asNumber of ARGS
. It could be 0, 1, any (*
), or at least one (+
). (:h :command-args
). Over the years, I've implemented quite a few commands. See some of the simplest ones: github.com/LucHermitte/lh-misc/blob/master/plugin/… github.com/LucHermitte/lh-misc/blob/master/plugin/… – Luc Hermitte Oct 3 '17 at 0:43<args>
,<f-args>
...), and the support for command-line completion -- I've ended-up with a set of helper functions to help me define command-line completion. – Luc Hermitte Oct 3 '17 at 0:46