이 기능을 .bashrc (또는 이와 동등한 버전)에 추가 할 수 있습니다. vim을 호출하기 전에 명령 줄 인수가 있는지 확인합니다. 정말로 새로운 파일을 만들고 싶다면 --new
을 전달하여 검사를 무시할 수 있습니다.
vim() {
local args=("[email protected]")
local new=0
# Check for `--new'.
for ((i = 0; i < ${#args[@]}; ++i)); do
if [[ ${args[$i]} = --new ]]; then
new=1
unset args[$i] # Don't pass `--new' to vim.
fi
done
if ! ((new)); then
for file in "${args[@]}"; do
[[ $file = -* ]] && continue # Ignore options.
if ! [[ -e $file ]]; then
printf '%s: cannot access %s: No such file or directory\n' "$FUNCNAME" "$file" >&2
return 1
fi
done
fi
# Use `command' to invoke the vim binary rather than this function.
command "$FUNCNAME" "${args[@]}"
}
감사합니다. 그러나 빈 파일을 보는 것의 추가 키 누름 (': q') + 놀라움을 피하고 싶습니다. 나는 터미널에 머물고 싶다. – user13107
'vim notexistencefile'은'notexistencefile'을 생성하지 않고 동일한 명명 된 버퍼를 생성합니다. ': q',': q!','ZQ'는이 경우 파일 쓰기 작업없이 Vim을 종료합니다. –