Is it possible to suppress the output of a register? For example, I am using getchar() to 'consume' a character, but I don't need it to return anything. I suppose I could add in a hackish ternary operator to do this, such as:


But I was wondering if there was a cleaner or better way to do this?

  • "cleaner" is subjective, but getchar()[-1] is shorter. – user938271 Jun 27 at 19:59
  • @user938271 thanks. Do you want to post an answer and show how that would work? Does the -1 work differently than for example it does in python? – David542 Jun 27 at 20:00

"cleaner" is subjective, but getchar()[-1] is shorter.

From :h expr-[]:

A negative index always results in an empty string (reason: backward compatibility).

| improve this answer | |
  • interesting...thanks for the explanation. – David542 Jun 27 at 20:07

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.