1

Consider the following text:

com.abc.JavaClassA.doSomething(JavaClassA.java:35)
com.abc.JavaClassA.doSomething(JavaClassA.java:35)
com.abc.JavaClassA$2.doSomething(JavaClassA.java:35)
com.abc.JavaClassA$1.doSomething(JavaClassA.java:35)

I run the command:

:%s/\v\.[^\.]{-}\(.*\)//ge | g/\v\$[0-9]+$/de | %sort u | %!uniq

I expect:

com.abc.JavaClassA

But the output is:

com.abc.JavaClassA
com.abc.JavaClassA$1

Why? I thought that com.abc.JavaClassA$1 should be deleted by g/\v\$[0-9]+$/de

3

According to vim's documentation, :global (aka :g) is not able to be used in a |-delimited command chain as | is one of its potential arguments. You can get around this with :execute:

:execute 'command1' | 'command2' [...]
  • Thanks. I've heard about :execute but havent' thought that it can help in this case. – ka3ak Jan 25 '17 at 16:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.