Skip to main content

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!.

CompletionResult
.aappend!foo = append(foo, █)
.append!append(foo, █)
.len!len(foo)█
.cap!cap(foo)█
.for!
for key, val := range foo {

}
.forkey!
for key := range foo {

}
.forvalue!
for _, val := range foo {

}
.nil!foo == nil█
.notnil!foo != nil█
.not!!foo█
.empty!foo == nil || len(foo) == 0█
.ifempty!
if foo == nil || len(foo) == 0 {

}
.if!
if foo {

}
.ifnot!
if !foo {

}
.ifnil!
if foo == nil {

}
.ifnotnil!
if foo != nil {

}
.check!
val, err := foo
if err != nil {

}
.defstruct!
type foo struct {

}
.definterface!
type foo interface {

}
.switch!
switch foo {

}