Skip to content

Instantly share code, notes, and snippets.

@sooop
Last active August 29, 2015 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sooop/9243127 to your computer and use it in GitHub Desktop.
Save sooop/9243127 to your computer and use it in GitHub Desktop.

:g[lobal]

사용법 : :[range]g[lobal]/{pattern}/[cmd]

주어진 범위에 대해 패턴에 매칭하는 줄에 대해서만 주어진 명령을 실행한다.

사용예

빈줄을 모두 삭제하는 명령

:%g/^$/normal dd

이때 명령은 명령모드 명령이다. 따라서 키 시퀀스 명령을 쓰려면 normal을 사용하 면된다.

참고

반대로 패턴에 매칭되지 않는 경우에만 실행하려면 **:g!**를 사용한다. 이와 동치의 명령으로는 :v가 있다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment