alex
alex

Reputation: 7601

How to remove the two words/characters between other two words/characters?

In other words, how I turn this:

isDefault   預設      Default 初期設定
none    無       None    無
buyNow  現在購買        Buy now すぐ購入

into this?

isDefault 初期設定
none 無
buyNow すぐ購入

(Note that the spacing has to be turned into a single one.)

Upvotes: 0

Views: 41

Answers (1)

Sundeep
Sundeep

Reputation: 23667

:%s/\s.*\s/ /
  • \s.*\s all characters from first whitespace up to last whitespace in the line
  • replace this with single space


same concept with calling awk command

:%!awk '{print $1,$NF}'

will retain only first and last field

Upvotes: 2

Related Questions