Vim 스왑 / 백업 / 실행 취소 파일 이름 변경
Vim이 스왑 / 백업 / 실행 취소 파일의 이름을 지정하는 방식을 변경할 수 있습니까?
혼란을 피하기 ~/.vimrc
위해이 파일을 덤프하는 옵션을 설정 했습니다 ~/.vim/tmp/{swap,backup,undo}
. 그러나 같은 이름을 가진 다른 디렉토리에있는 파일을 일상적으로 편집 할 때 종종 구별 할 수없는 많은 파일이 생성되고 Vim은 때때로 복구하는 데 문제가 있습니다.
이상적으로는 %path%to%file.undo
이러한 모든 보조 파일에 대해 영구 실행 취소에있는 이름 지정 체계 ( ) 를 사용하고 싶습니다 . 설정하는 명확한 방법은 없지만 Buf{Read,Write}
매크로 로 수행 할 수 있습니까?
나는 이것을 가지고 있으며 .vimrc
설명하는 것처럼 전체 경로 이름과 백분율 기호로 스왑 파일의 이름을 지정합니다.
" Store swap files in fixed location, not current directory.
set dir=~/.vimswap//,/var/tmp//,/tmp//,.
키는 //
디렉토리 끝에 있습니다. 다음에서이 메모를 참조하십시오 :help dir
.
- Unix 및 Win32의 경우 디렉토리가 두 개의 경로 구분 기호
"//"
또는 로 끝나는 경우"\\"
스왑 파일 이름은 모든 경로 구분 기호가 퍼센트 '%'기호로 대체 된 파일의 전체 경로에서 빌드됩니다. 이렇게하면 보존 디렉터리에서 파일 이름의 고유성이 보장됩니다.
다음 .vimrc
은 github 의 일부입니다 .
이렇게하면 설정 undodir
(및 켜짐) backupdir
,, 및 directory
( .swp
파일에 사용됨 )이 설정됩니다. 아직 존재하지 않는 경우 디렉토리를 생성합니다.
" Save your backup files to a less annoying place than the current directory.
" If you have .vim-backup in the current directory, it'll use that.
" Otherwise it saves it to ~/.vim/backup or .
if isdirectory($HOME . '/.vim/backup') == 0
:silent !mkdir -p ~/.vim/backup >/dev/null 2>&1
endif
set backupdir-=.
set backupdir+=.
set backupdir-=~/
set backupdir^=~/.vim/backup/
set backupdir^=./.vim-backup/
set backup
" Save your swap files to a less annoying place than the current directory.
" If you have .vim-swap in the current directory, it'll use that.
" Otherwise it saves it to ~/.vim/swap, ~/tmp or .
if isdirectory($HOME . '/.vim/swap') == 0
:silent !mkdir -p ~/.vim/swap >/dev/null 2>&1
endif
set directory=./.vim-swap//
set directory+=~/.vim/swap//
set directory+=~/tmp//
set directory+=.
" viminfo stores the the state of your previous editing session
set viminfo+=n~/.vim/viminfo
if exists("+undofile")
" undofile - This allows you to use undos after exiting and restarting
" This, like swap and backup files, uses .vim-undo first, then ~/.vim/undo
" :help undo-persistence
" This is only present in 7.3+
if isdirectory($HOME . '/.vim/undo') == 0
:silent !mkdir -p ~/.vim/undo > /dev/null 2>&1
endif
set undodir=./.vim-undo//
set undodir+=~/.vim/undo//
set undofile
endif
바라건대, 무슨 일이 일어나고 있는지 이해하기에 충분히 주석이 달렸 으면합니다. 그렇지 않은 경우 댓글을 추가하면 수정하겠습니다.
챠오!
업데이트 [2012 년 7 월 16 일]
저는 Rob Kine으로부터 backupdir
제가 모든 사람에게 답하고 싶은 섹션 에 대해 다음과 같은 질문을하는 이메일을 받았습니다 .
- It looks like you are removing the current directory, and then re-adding it. what does that do?
- What does the
^=
operator do? - How does the order of precedence in the use of folders checked work in Vim? (Like is the last folder added the first one it checks for?)
The first thing is to describe the different operators. These operators have different meanings for non-string-list options, so be warned!
-=
removes the value from a string list;+=
appends the value to a string list;^=
prepends the value to a string list.
So the backupdir
has the following operations applied:
- Remove the current directory from the list.
- Append the current directory to the list (this ensures it is the last thing checked).
- Remove the home directory from the list (I don't like stuff being saved there).
- Prepend
~/.vim/backup/
. - Prepend
~/.vim-backup/
.
When Vim looks for where to save the backups, it checks from first to last; so it'll check for ~/.vim-backup/
, then check for ~/.vim/backup
, then check the default list (except for .
and ~/
which were removed), and finally check .
You can get help for all these in Vim by using (for example) :help ^=
or :help backupdir
.
Create the directory undo
$ mkdir ~/.vimundo
Set up your .vimrc file
set undodir=~/.vimundo
ReferenceURL : https://stackoverflow.com/questions/4331776/change-vim-swap-backup-undo-file-name
'programing' 카테고리의 다른 글
주소 0에 액세스하고 싶을 수 있습니까? (0) | 2021.01.17 |
---|---|
휘발성 롱을 사용하는 데 어떤 의미가 있습니까? (0) | 2021.01.17 |
여러 아키텍처에 최적화 된 NDK 코드를 생성하고 계십니까? (0) | 2021.01.17 |
특정 날짜 이전에 기록 삭제 (0) | 2021.01.17 |
AngularJS에서 사용자가 템플릿 / 페이지를 떠날 때 감지하는 방법은 무엇입니까? (0) | 2021.01.16 |