vim 컴파일. makeprg, cope, vertical terminal

개요

임베디드 뿐만아니라 컴파일하고 개발할때 편리한 vim 기능 입니다.


makeprg

make 시 make를 하지 않고 실행할 프로그램을 지정해줍니다.

make 후 이런저런 해야할일을 스크립트로 만들어서 쓰고 있는 제게 매우 편리한 기능입니다.

저는 ~/.vimrc에 아래와 같이 지정해주었습니다.

set makeprg=./build.sh

vim에서 :make 해보면 ./build.sh 가 호출되는 것을 확인할 수 있습니다.

copen

:help copen

                                            :cope :copen w:quickfix_title

:cope[n] [height]       Open a window to show the current list of errors.

현재(current) 에러를 open 하는거네요. 
처음에 cope로 썼는데 이게 왜 cope 이게 컴파일 로그를 보는데 쓰이는지 몰랐습니다.

:make 를 했으면 에러 로그를 봐야죠. 

:cope

vertical terminal

:vertical 명령에 cmd를 terminal 을 넘겨주는겁니다.

:vertical terminal make

위와 같이 해보면 좌측 창에 make 결과가 텍스트로 올라옵니다. 생각보다 편해서 자주 씁니다.

하지만 매번 vertical terminal 을 쓸수는 없죠.

~/.vim 에 다음과 같이 추가합니다.

cnoreabbrev Vt vertical terminal

:Vt 명령을 넣으면 자동으로 vertical terminal로 변하니 쓰기 편합니다.

croreabbrev 는 약어(abbreviations)입니다. 자세한 설명은 아래와 같습니다.

:ab[breviate] {lhs} list the abbreviations that start with {lhs}
    You may need to insert a CTRL-V (type it twice) to
    avoid that a typed {lhs} is expanded, since
    command-line abbreviations apply here.
:cnorea[bbrev] [<expr>] [<buffer>] [lhs] [rhs]
    same as ":ab", but for Command-line mode only and no
    remapping for this {rhs}



댓글

이 블로그의 인기 게시물

WSL2 Ubuntu 20.04 및 네트워크 설정

리눅스 멀티코어를 사용하는 tar 압축/해제

git pull 을 했더니 branch가 갈라지는 경우