:へ
//@brief: an example => TO LINE IS REMOVED
anExampleOfFunction:{[x;y]
x: doing some stuff; //a comment => after // is removed
//a comment => this is removed
:y;
};
someVariable: 5;
//another comment => this is removed
anotherFunction:{[x] 2*x};
:
私から行くことができますどのよう
、例えば、この
:%s`\(//.\+\)\?\n``
コメントと改行が削除されます。
ご例えば
、それはあなたの次の結果が得られます:
anExampleOfFunction:{[x;y] x: doing some stuff; :y; }; someVariable: 5; anotherFunction:{[x] 2*x};
編集:ここでは
は(それが代わりにその引数で動作しますを除いて)同じことを行う関数です。
function! Format(lines)
let lines = []
for line in a:lines
let new_line = substitute(line, '//.*', '', '')
call add(lines, new_line)
endfor
return join(lines)
endfunction
マッピングやコマンドだけでなく、元のテキストと期待されるテキストの例を追加することもできます。それで、あなたがしたいことを理解し、それに答えるのは簡単です – SibiCoder
各行に行き、 'f /'を押してコメントを見つけ、 'df $'を押して終わりを削除します。次に、Jを押して、次の行と結合します。 3Jを押すと現在の行が次の2行と結合されます。たとえば – SibiCoder