Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

When I try to launch vi using vi or vim, it fails to start.

ozzesh:~ # clear
ozzesh:~ # vi 
ozzesh:~ # echo $?
0
ozzesh:~ # 

The above vi / vim command can't launch vi.

share|improve this question
    
What does which vim or type vim tell you? – choroba May 2 '13 at 8:42
    
ozzesh:~ # which vim /usr/bin/vim ozzesh:~ # type vim vim is hashed (/usr/bin/vim) ozzesh:~ # – Özzesh May 2 '13 at 8:44
    
Try running strace vim or strace -f vim. – choroba May 2 '13 at 8:55
    
ozzesh:~ # strace vim execve("/usr/bin/vim", ["vim"], [/* 58 vars */]) = -1 ENOEXEC (Exec format error) dup(2) = 3 fcntl(3, F_GETFL) = 0x8002 (flags O_RDWR|O_LARGEFILE) fstat(3, {st_mode=S_IFCHR|0620, st_rdev=makedev(136, 0), ...}) = 0 mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f545c8a4000 lseek(3, 0, SEEK_CUR) = -1 ESPIPE (Illegal seek) write(3, "strace: exec: Exec format error\n", 32strace: exec: Exec format error – Özzesh May 2 '13 at 9:01
    
Your vim is corrupted. Try reinstalling it: zypper remove vim ; zypper install vim – choroba May 2 '13 at 9:04

Normally vi / vim are located in /usr/bin.

Try /usr/bin/vi and /bin/vi. If these work then your PATH settings need correcting.

Check path, it should contain /bin and /usr/bin -:

echo $PATH

Correct path by reading in your .bash_profile into your current shell (or login again)

cd
source .bash_profile
share|improve this answer
    
ozzesh:~ # /usr/bin/vi ozzesh:~ # /bin/vi ozzesh:~ # echo $PATH /sbin:/usr/sbin:/usr/local/sbin:/root/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin/‌​X11:/usr/X11R6/bin:/usr/games:/opt/kde3/bin:/usr/lib/mit/bin:/usr/lib/mit/sbin ozzesh:~ # still not working...... – Özzesh May 2 '13 at 8:46
    
ls -l /usr/bin/vim – suspectus May 2 '13 at 8:52
    
ozzesh:~ # ls -l /usr/bin/vim lrwxrwxrwx 1 root root 8 May 20 2010 /usr/bin/vim -> /bin/vim ozzesh:~ # – Özzesh May 2 '13 at 8:53
    
ls -l /bin/vim – suspectus May 2 '13 at 8:54
    
ozzesh:~ # ls -l /bin/vim lrwxrwxrwx 1 root root 21 May 20 2010 /bin/vim -> /etc/alternatives/vim ozzesh:~ # – Özzesh May 2 '13 at 8:56

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .