Postfix Completion
CodePerfect supports a number of postfix completions. Postfix completions are basically a type of macro that you trigger as if they were methods on whatever you're typing:
For instance, if you type foo.
, it will show you postfix completions such as
ifnotnil!
. If you select that, it replaces foo.
with
if foo != nil {
█
}
and places your cursor where the grey block is. (It doesn't add an actual block character, it's there in the example to mark where the cursor moves.)
Postfix completions provide shortcuts that operate on some expression, to
complete certain idioms or phrases. For instance, x.append!
becomes
append(x, █)
, and x.aappend!
(for "assign append") becomes
x = append(x, █)
.
note
To use a postfix completion, you have to type x.
and then actually select
append!
from the menu. Nothing will happen if you just type out x.append!
manually.
Supported Completions
The examples all assume the completion is operating on an expression foo
, e.g.
foo.append!
.
Completion | Result |
---|---|
.aappend! | foo = append(foo, █) |
.append! | append(foo, █) |
.len! | len(foo)█ |
.cap! | cap(foo)█ |
.for! |
|
.forkey! |
|
.forvalue! |
|
.nil! | foo == nil█ |
.notnil! | foo != nil█ |
.not! | !foo█ |
.empty! | foo == nil || len(foo) == 0█ |
.ifempty! |
|
.if! |
|
.ifnot! |
|
.ifnil! |
|
.ifnotnil! |
|
.check! |
|
.defstruct! |
|
.definterface! |
|
.switch! |
|