vi - How to stop Vim from creating/opening a new file? -


vim creates new files when give name of non existing file. undesirable me, give wrong file name , have no intention open file, , close it.

is there way stop vim opening new files? example, when vi file1, should file doesn't exist , stay on bash terminal (without opening vi window)

you add function .bashrc (or equivalent). checks command-line arguments exist before invokes vim. if want create new file can pass --new override checks.

vim() {     local args=("$@")     local new=0      # check `--new'.     ((i = 0; < ${#args[@]}; ++i));         if [[ ${args[$i]} = --new ]];             new=1             unset args[$i]   # don't pass `--new' vim.         fi     done      if ! (( new ));         file in "${args[@]}";             [[ $file = -* ]] && continue   # ignore options.              if ! [[ -e $file ]];                 printf '%s: cannot access %s: no such file or directory\n' "$funcname" "$file" >&2                 return 1             fi         done     fi      # use `command' invoke vim binary rather function.     command "$funcname" "${args[@]}" } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -