Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.
user@laptop:~$ locate file.ext | xargs vim -p
Vim: Warning: Input is not from a terminal
2 files to edit
user@laptop:~$ 

After finding files and modifying them in vim I want to save them and continue to work in unix console but I can't do that.

After vim close console just halts. No activity on any keypress. The only workaround is to close console tab and create a new one. How can I solve this problem?

share|improve this question

migrated from stackoverflow.com Jun 18 '10 at 11:38

This question came from our site for professional and enthusiast programmers.

add comment

3 Answers

try to run it different way:

vim -p `locate file.ext`

or you can try to run reset command after your vim session, to reset terminal options to defaults:

locate file.ext | xargs vim -p; reset
share|improve this answer
    
great! thank you –  Anonymous Jun 18 '10 at 10:05
    
please accept an answer by putting a checkmark sign under it if it helped you. thank you –  zed_0xff Jun 18 '10 at 10:07
1  
Don't use the second one, it's a hack; the first command is the idiomatic and correct way to do it. –  msw Jun 18 '10 at 12:21
add comment

This is what I do, after exiting vim from a piped command on Cygwin.

stty sane {enter}

Of course, you won't see that get typed, but after you hit enter, the tty will come back to life. It's a pain, but works.

I don't like the other solution here because often I am running a much more complex lookup than a file lookup. I might do something like this:

egrep -ri [pattern] * | sed -e 's:\:.*::g' | grep -v ^Binary | sort | uniq | xargs vim

In my work (10 year old fast moving codebase), this kind of search is so common that I have the first five commands in a single shell script that I pipe to vim.

share|improve this answer
    
Couldn't you do vim $(callToBashScript)? –  Niels Bom Aug 7 '12 at 14:44
add comment
Vim: Warning: Input is not from a terminal

A pipe is not a terminal as such, but have you tried fg?

share|improve this answer
    
fg what? there is no background job here –  unbeli Jun 18 '10 at 10:01
    
Tried the exact same line in my terminal and got a running Vim process accesible via fg. –  matiasf Jun 18 '10 at 10:10
    
Matias, can you please share your command? I haven't heard of fg before. How can I use it? –  Anonymous Jun 18 '10 at 10:23
    
"fg" means foreground, swapping a paused process from background to foreground in your terminal. Try "man bash", then pause it by Ctrl-Z. Then issue "fg". –  matiasf Jun 18 '10 at 11:04
    
It isn't running in the background, its standard input is attached to the pipe from locate, thus "Input is not from a terminal" is accurate. –  msw Jun 18 '10 at 12:20
add comment

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.