vim에서 '@' 을 일반 문자로 인식시키는 방법?

김도현의 이미지

아시다사피 vim에서 CTRL-n 누르면 낱말자동완성 기능이 작동합니다.

TeX 프로그래밍할 때 @ 문자를 상당히 많이 쓰는데, vim은 이것을 특수문자로 인식하고 어절을 끊어버려서 불편합니다.

예컨대 다음 같은 명령을 정의하였다면

\def\this@is@unichar@or@not{...}

이후로 \this만 치고 CTRL-n 누르면 \this@is@unichar@or@not까지 완성되면 좋겠는데, 방법이 있을까요?

nohmad의 이미지

단어의 경계를 나타내는 정규 표현(\b, \B)으로 사용되기 때문에 그런 것 같군요.

vim에서
:echo &iskeyword
를 해보시고, 보이는 목록 중에서 @을 제외한 나머지를, 제 경우라면 아스키값으로 보이는 48-57,192-255를
:set iskeyword=48-57,192-255
과 같은 식으로 재설정해주니, @을 더 이상 단어 경계로 인식하지 않는군요. w 같은 단어 이동 기능의 동작이 바뀝니다.

김도현의 이미지

nohmad wrote:
단어의 경계를 나타내는 정규 표현(\b, \B)으로 사용되기 때문에 그런 것 같군요.

vim에서
:echo &iskeyword
를 해보시고, 보이는 목록 중에서 @을 제외한 나머지를, 제 경우라면 아스키값으로 보이는 48-57,192-255를
:set iskeyword=48-57,192-255
과 같은 식으로 재설정해주니, @을 더 이상 단어 경계로 인식하지 않는군요. w 같은 단어 이동 기능의 동작이 바뀝니다.

전 이렇게 해도 안 되길래 :help iskeyword 해서 보다가 isfname의 문법을 참조하라길래 CTRL-] 해서 자세히 읽고나서 해답을 찾았습니다.

여기서 @은 a-zA-Z의 의미로 사용되는 것이었고, '@' 문자 자체를 지시하기 위해서는 '@-@'을 써야한답니다. 따라서

:set iskeyword=@,48-57,192-255,@-@

이렇게 해 줘서 원하는 바를 이룰 수 있었습니다. 감사합니다.

nohmad의 이미지

그렇군요. 제가 완전히 잘못 알고 대답을 했습니다. :roll:
help를 자세히 안 읽고, iskeyword에서 @을 제거한 후에 w가 @을 건너뛰는 것을 보고 @가 단어 경계의 의미를 잃은 것이라고 생각했는데, 지금 isfname 섹션을 읽으니 조금 알겠군요. 덕분에 저도 하나 배웠습니다. 앞으로 써먹을 일이 있을 것 같네요.

:help isfname wrote:
"a-z,A-Z,@-@" All letters plus the '@' character.

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.