[완료]vim 에서 컴파일하고 에러 확인하기

oosap의 이미지

vim 에서 소스코드 편집중에 :make 명령을 수행하면 컴파일을 수행하게 되고 컴파일 결과 메세지에서 enter 키를 누르면 첫번째 에러 메세지로 커서가 이동되는 걸 확인했습니다.
:help usr_30.txt 에서 자세한 설명이 있네요.
그리고 이렇게 컴파일을 한 후에는 :cc :cn :cp :clist 등 다양한 명령으로 컴파일 결과에서 이동할 수 있는 것도 보았습니다.

놀랍고 반가운 기능입니다.

그런데 소스코드가 여러 디렉토리에 나누어져있고 메이크파일도 여러 곳에 분산되어 있는 상황에서는 잘 안되는군요..
폴더마다 메이크 파일이 하나씩 들어있고 재귀적으로 맨 상위의 경로에서 make 를 하면 모든 폴더내의 코드들이 빌드되는 구조 입니다.

이런 경우에는 이와 같은 :make 신공을 사용할 수 없는 것인가요?
사용하기 위해서는 특별한 설정이 필요한가요?

감사합니다.

http://kldp.org/node/71801

에서 이어질만한 내용인데 질문의 포인트가 조금 달라서 새글로 올렸습니다.

qiiiiiiiip의 이미지

소스코드가 여러 디렉토리에 나누어져있고 메이크파일도 여러 곳에 분산되어 있는 상황에서도,
별다른 설정없이 잘 사용하고 있습니다..

다만 "상위" 디렉토리에서 vim을 시작해야합니다.
아니면 현재 디렉토리(:pwd)의 makefile이 수행되겠지요.

혹시 자동으로 "최상위" 디렉토리를 찾는 방법을 물어보시는 거라면,
잘 모르겠네요..

oosap의 이미지

맞습니다!
저는 .vimrc 파일에 아래와 같은 설정을 두고 쓰고 있습니다.

autocmd BufEnter * silent! lcd %:p:h:gs/ /\\/

이것도 여기 게시판에서 배워서 잘 쓰고 있는데 내용인즉, 현재 열린 파일버퍼의 위치로 디렉토리가 설정되는 것이예요. 그러니 :make 를 수행하면 최 상위에서 make 를 수행하지 않고 현재 서브 폴더에서 make 를 수행했네요..

정말 자동으로 최상위 디렉토리로 가서 make 를 수행하도록 빔 스크립트를 만들면 되겠군요..

감사합니다..

Thanks for being one of those who care for people and mankind.
I'd like to be one of those as well.

oosap의 이미지

"============ make setting =============
let startdir = getcwd()
func! Make()
exe "!cd ".startdir
exe "make"
endfunc
nmap ,mk :call Make()

vim 시작을 소스코드의 최상위에서 시작하기만 한다면 위의 .vimrc 설정으로 해결이 됩니다.
아주 유용한 팁이었습니다. 점점 vim 이 손가락에 붙는 것 같아서 기분이 좋으네요..
소스 최상위에서 시작시에도 vi ./ 대신 v 라는 한글자의 얼라이어스로 쓸 생각입니다. ㅎㅎ

Thanks for being one of those who care for people and mankind.
I'd like to be one of those as well.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.