vim을 사용하여 공백이 포함 된 빈 줄을 감지하고 공백을 삭제하려면 어떻게해야합니까?
예를 들어 ⎵
공백을 나타내는 데 사용 합니다.
def⎵function(foo):
⎵⎵⎵⎵print(foo)
⎵⎵
⎵
function(1)
위의 코드를 다음으로 변환하는 vim 명령이 있습니까?
def⎵function(foo):
⎵⎵⎵⎵print(foo)
function(1)
:g/^\s\+$/s/\s\+//
설명:
g — execute the command globally (for all lines)
/^\s\+$/ — search lines that contain only whitespaces
s/\s\+// — for every found line execute this
search and replace command:
search whitespaces and replace with an empty string.
다음과 같이 단순화 할 수 있습니다.
:%s/^\s\+$//
% — execute for all lines
s/^\s\+$// — search and replace command:
search lines that only have whitespaces
and replace with an empty string.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다