Create TOC

레이블이 vim인 게시물을 표시합니다. 모든 게시물 표시
레이블이 vim인 게시물을 표시합니다. 모든 게시물 표시

2016년 10월 11일

Vim 8.0/Win32에서 vim-signify 오류 수정

한글 Windows 7 환경에서 Vim 8.0 x64 빌드를 사용할 경우 vim-signify 플러그인에서 오류가 발생한다.

lang mes C를 해도 메시지가 한글로 표시되기 때문에 나타나는 문제이다. 아래와 같이 소스를 수정해주면 문제가 해결된다.

diff --git a/autoload/sy/fold.vim b/autoload/sy/fold.vim
index 35028d8..a51ef54 100644
--- a/autoload/sy/fold.vim
+++ b/autoload/sy/fold.vim
@@ -100,7 +100,11 @@ function! s:get_lines() abort

   let lines = []
   for line in split(signlist, '\n')[2:]
-    call insert(lines, matchlist(line, '\v^\s+line\=(\d+)')[1], 0)
+    let tokens = matchlist(line, '\v^\s+line\=(\d+)')
+    if 0 == len(tokens)
+      let tokens = matchlist(line, '\v^\s+줄\=(\d+)')
+    endif
+    call insert(lines, tokens[1], 0)
   endfor

   return reverse(lines)
diff --git a/autoload/sy/sign.vim b/autoload/sy/sign.vim
index 6af68ff..2cd818b 100644
--- a/autoload/sy/sign.vim
+++ b/autoload/sy/sign.vim
@@ -30,9 +30,11 @@ function! sy#sign#get_current_signs() abort
     silent! execute 'sign place buffer='. b:sy.buffer
   redir END
   silent! execute 'language message' lang
-
   for signline in split(signlist, '\n')[2:]
     let tokens = matchlist(signline, '\v^\s+line\=(\d+)\s+id\=(\d+)\s+name\=(.*)$')
+    if 0 == len(tokens)
+      let tokens = matchlist(signline, '\v^\s+줄\=(\d+)\s+id\=(\d+)\s+이름\=(.*)$')
+    endif
     let line   = str2nr(tokens[1])
     let id     = str2nr(tokens[2])
     let type   = tokens[3]

수정 후 fold.vim은 cp949, sign.vim은 utf-8로 저장해야 한다.

Vim/Win32 메뉴 표시 언어를 영어로 고정

아래와 같은 내용을 _vimrc에 추가한다.


if has('win32')
 lan mes en_US
 if has('menu') && has('multi_lang') && has('gui_running')
  set langmenu=en_US
  source $ViMRUNTIME/delmenu.vim
  source $ViMRUNTIME/menu.vim
 endif
endif

2016년 7월 11일

Vim/Win32에서 CtrlSF 가 동작하지 않을때

Windows환경의 Vim x64에서 CtrlSF 플러그인이 동작하지 않으면 아래와 같이 shellescape을 적당히 바꾸어 준다.

--- a/autoload/ctrlsf/backend.vim
+++ b/autoload/ctrlsf/backend.vim
@@ -110,7 +110,11 @@ func! s:BuildCommand(args) abort
     endif
 
     " pattern (including escape)
-    call add(tokens, shellescape(ctrlsf#opt#GetOpt('pattern')))
+    if has('win32')
+  call add(tokens, '"' . ctrlsf#opt#GetOpt('pattern') . '"')
+ else
+  call add(tokens, shellescape(ctrlsf#opt#GetOpt('pattern')))
+ endif
 
     " path
     call extend(tokens, ctrlsf#opt#GetPath())
--- a/autoload/ctrlsf/opt.vim
+++ b/autoload/ctrlsf/opt.vim
@@ -139,7 +139,11 @@ func! ctrlsf#opt#GetPath() abort
             let resolved_path = expand(path, 0, 1)
 
             for r_path in resolved_path
-                call add(path_tokens, shellescape(r_path))
+    if has('win32')
+     call add(path_tokens, '"' . r_path . '"')
+    else
+     call add(path_tokens, shellescape(r_path))
+    endif
             endfo
         endfo
     else
@@ -151,7 +155,11 @@ func! ctrlsf#opt#GetPath() abort
         if empty(path)
             let path = expand('%:p')
         endif
-        call add(path_tokens, shellescape(path))
+  if has('win32')
+   call add(path_tokens, '"' . path . '"')
+  else
+   call add(path_tokens, shellescape(path))
+  endif
     endif
 
     return path_tokens

2014년 2월 4일

Vim/Win32에서 VCSCommand가 'no suitable plugin' 오류를 내면서 동작하지 않을 때

Windows 7 x64에서 64bit로 빌드된 vim을 사용 중인데 VCSCommand로 svn을 사용하려고 하면 'no suitable plugin' 오류가 발생한다.

원인은 외부 명령 실행시 'svn' info . 식으로 실행 명령에 ' 가 붙기 때문인데 vcssvn.vim 파일을 수정한다.

--- a/plugin/vcssvn.vim
+++ b/plugin/vcssvn.vim
@@ -72,6 +72,9 @@ let s:svnFunctions = {}
 " Returns the executable used to invoke git suitable for use in a shell
 " command.
 function! s:Executable()
+       if has ('win32')
+               return VCSCommandGetOption('VCSCommandSVNExec', 'svn')
+       endif
        return shellescape(VCSCommandGetOption('VCSCommandSVNExec', 'svn'))
 endfunction

vcssvn.vim을 수정하면 'no suitable plugin' 오류는 나지 않지만 VCSInfo 등의 명령을 실행할 때 파일 명에 ' 가 붙어서 실패하게 된다.

이 문제는 vcscommand.vim을 수정해야 한다.

--- a/plugin/vcscommand.vim
+++ b/plugin/vcscommand.vim
@@ -1235,7 +1235,11 @@ function! VCSCommandDoCommand(cmd, cmdName, statusText, options)
     if match(a:cmd, '<VCSCOMMANDFILE>') > 0
         let fullCmd = substitute(a:cmd, '<VCSCOMMANDFILE>', fileName, 'g')
     else
-        let fullCmd = a:cmd . ' -- ' . shellescape(fileName)
+        if has ('win32')
+            let fullCmd = a:cmd . ' -- "' . fileName .'"'
+        else
+            let fullCmd = a:cmd . ' -- ' . shellescape(fileName)
+        endif
     endif

     " Change to the directory of the current buffer.  This is done for CVS, but

2014년 1월 6일

Vim/Win32환경에서 한글이 포함된 경로의 파일에 대해 python mode가 동작하지 않는 문제

Win32환경에서 한글이 포함된 경로의 python 파일에 대해 python mode 확장이 제대로 동작하지 않는다.

vundle을 사용할때 기준으로 ~/.vim/bundle/python-mode/pymode/environment.py 파일을 수정해야 한다.

아래는 patch 내용이다.

--- pymode/environment.py_org    2014-01-06 08:44:00.971905800 +0900
+++ pymode/environment.py    2014-01-06 09:21:12.068213500 +0900
@@ -6,6 +6,7 @@
 import json
 import time
 import os.path
+import platform

 from .utils import PY2

@@ -199,11 +200,19 @@

         """

-        if dumps:
-            value = json.dumps(value)
+        if platform.system() != 'Windows':
+            if dumps:
+                value = json.dumps(value)
+
+            if PY2:
+                value = value.decode('utf-8').encode(self.options.get('encoding'))
+        else:
+            # win32 patch
+            if dumps:
+                value = json.dumps(value, ensure_ascii=False, encoding='cp949').encode('cp949')

-        if PY2:
-            value = value.decode('utf-8').encode(self.options.get('encoding'))
+            if PY2:
+                value = value.decode('cp949').encode(self.options.get('encoding'))

         return value
environmemt-win32.path

2012년 7월 12일

VIM/'unable to open swap file for "[No Name", recovery impossible' 오류 수정

Windows에서 VIM을 쓰다보면 unable to open swap file for "[No Name", recovery impossible 오류가 나는 경우가 있다. 임시 파일 생성 경로에 권한이 없는 경우 발생하는데, %USERPROFILE%/_vimrc 파일에 아래와 같이 임시파일 생성 경로를 지정해주면 된다.

if has ('win32')
	set directory=.,$TEMP
endif

2011년 6월 25일

Vim/파일을 tab으로 열기

vim으로 파일을 열 때 새 창이 아닌 새 탭으로 열게 하는 방법은 아래와 같다.

OS

Linux

아래와 같은 shell script를 작성하고 gvim으로 저장한다.

#!/bin/bash

GVIM=/usr/bin/gvim

if [ $# -lt 1 ]; then
 $GVIM
 exit 0;
fi;

DIFFMODE=0

params=()
filenames=()

for arg do
 IDX=`expr index "$arg" -`
 if [ $IDX -eq 1 ] ; then
  if [ "$arg" = "-d" ] ; then
   DIFFMODE=1
  fi;
  params+=("$arg")
 else
  filenames+=("$arg")
 fi;
done;

if [ ${#filenames[*]} -eq 0 ]; then
 $GVIM ${params[@]}
else
 if [ $DIFFMODE -eq 0 ]; then
  params+=("--remote-tab-silent")
 fi;
 $GVIM ${params[@]} --remote-tab-silent "${filenames[@]}"
fi;

저장한 파일을 /usr/bin/gvim보다 먼저 실행 할 수 있도록 PATH에서 /usr/bin 앞의 경로에 저장한다. 보통은 $HOME/bin을 /usr/bin보다 앞에 있도록 설정하고 $HOME/bin에 넣는다.

OS/X

MacVim 설정에서 Open files from applications을 아래 그림처럼 설정해주면 된다.

Windows

레지스트리 HKEY_CLASSES_ROOT\Applications\gvim.exe\shell\edit\command에서 gvim.exe 뒤에 --remote-tab-silent을 추가한다. 이 작업이 귀찮다면 vim-tabs.reg 파일을 받아서 레지스트리에 병합한다.

App

cpp check

응용 프로그램에 gvim을 등록하고 명령행을 아래와 같이 설정한다.

--remote-tab-silent "+:(line)" (file)

2010년 12월 9일

Vim/빈 줄 삭제하기

아래 명령을 이용해서 빈 줄을 삭제할 수 있다.

:g/^$/d