0

次のファイルがあります。

mr l 0x19600000 0x00004341
mr l 0x19600004 0x00004820
mr l 0x19600008 0x00003130
mr l 0x1960000c 0x00003920

各行の最後の部分を削除したいと思います。したがって、上記の例では、削除したい

0x00004341
0x00004820
...

等々。

ファイルは約4000行で構成されているので、正規表現を使用する必要があると思います。

問題は、これをどのように行うかです。

4

4 に答える 4

6

カーソルを最初0x00004341の. _CtrlVGEd

または、次を実行できます。

%s/^\(.* \)[^ ]\+$/\1/g
于 2013-06-27T08:35:45.397 に答える
4

簡単な方法の 1 つを次に示します。

:%s/ [^ ]\+$//g

ここにいくつかの説明があります:

  %      for the whole document
  s      substitute
  /      begin substitution pattern
         a space
  [^ ]   anything but a space
  \+     one or more of the previous pattern (must escape + with \)
  $      end of line
  /      end substitution pattern/begin replacement pattern
  /      end  replacement pattern (i.e. replace with empty string)
  g      perform multiple times per line (does nothing here)
于 2013-06-27T09:04:53.853 に答える
2

最後の部分だけを削除したい場合:

:%s/[^ ]*$

最後の部分とその先頭のスペースを削除する場合:

:%s/ *[^ ]*$
于 2013-06-27T08:44:09.843 に答える
1

Supposing all the lines look the same, you can do it with a macro:

qq
0
3f <-- space
D
q

then:

:%norm @q
于 2013-06-27T08:46:44.700 に答える