Home > Message-Formatter

Message-Formatter

Message-Formatter is a project mainly written in Vim Script, it's free.

An autoload plugin to format strings with parameters

This is a mirror of http://www.vim.org/scripts/script.php?script_id=3552

This plugin allows the simplification of repetitive code fragments, allowing much faster entry; for example, this text getset List names

gets converted to public List getNames() { return m_names; }

    public void setNames( List<String> val )
    {
            m_names = val;
    }

More importantly, it figures out when you're defining a boolean variable and replaces the "get" with "is"; thus, getset boolean old enough

becomes public boolean isOldEnough() { return m_oldEnough; }

    public void setOldEnough( boolean val )
    {
            m_oldEnough = val;
    }

Observe how "old enough" was automatically camel-cased to "oldEnough", and, when used with "get" or "is", was also capitalized. The same variable can be used over and over again, each time with (if desired) different formatting directives; for example, this template pattern My name is {john::f_fName} and my full name is {{fName} smith::uq_fullName}.

gets expanded to My name is John and my full name is "JOHN SMITH".

Observe, also, how the "fullName" directive recursively contained and expanded the fName directive.

In the "getset" example, the "get" is defined as:

Addlocaltemplate get public {::type} {eval '{type}' ==? 'boolean' ? 'is' : 'get'::get}{::cfproperty}()\n{\nreturn m{c_property};\n}

The "set" is defined as:

Addlocaltemplate set public void set{::cfproperty}( {::type} val )\n{\nm{c_property} = val;\n}

And the "getset" is defined simply as:

Addlocaltemplate getset {tem get::getTem}\n\n{tem set::setTem}

This allows "get" and "set" to be used independently (for read-only or write-only properties, for example) and doesn't require duplication of code to define a separate "getset".

Previous:arsapp