Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I'm using zsh on Gentoo x64, and when I type sudo vim /path/to/file from my home folder, zsh asks:

zsh: correct 'vim' to '.vim' [nyae]?

I want to run vim not my .vim folder. How do I fix this?

My guess is that setopt autocd is causing this. Odd thing is, if I don't add sudo, zsh doesn't ask to correct anything.

share|improve this question

2 Answers 2

up vote 5 down vote accepted

try alias sudo='nocorrect sudo'.

share|improve this answer
1  
nocorrect, eh? Does that just ignore corrections for just that command? I'll have to test this out later. –  Rocket Hazmat Oct 15 '12 at 14:02
    
unlike the chosen answer, this works. –  tiktak Feb 5 '13 at 19:50

OK, I got this. The problem isn't autocd, it's correctall. vim as a command (vim file) doesn't trigger any correction*, but vim in sudo vim is an argument, zsh sees that it's close to the name of a folder in the current directory, and asks if you want to change to that, as files and folders are more common arguments. So the solution is unsetopt correctall (or setopt nocorrectall). As illustration; note I have a .zsh folder:

% unsetopt correctall
% setopt autocd correct 
% vim zsh
% sudo vim zsh
% setopt correctall
% vim zsh
zsh: correct 'zsh' to '.zsh' [nyae]? 
% sudo vim zsh
zsh: correct 'zsh' to '.zsh' [nyae]? 
zsh: correct 'vim' to '.vim' [nyae]? 
%

*: Or shouldn't, I have had zsh ask if it should correct command to _command on a couple commands for some reason. Perhaps because it checks aliases and gives them higher priority.

share|improve this answer
    
Ah, that makes sense. I kinda like having correctall on, because I can't type, and I like how it'll correct ks to ls. Wonder if there's a way to change how zsh checks for "corrections". –  Rocket Hazmat Mar 18 '12 at 3:13

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.