What's new
DroidForums.net | Android Forum & News

This is a sample guest message. Register a free account today to become a member! Once signed in, you'll be able to participate on this site by adding your own topics and posts, as well as connect with other members through your own private inbox!

vi text editor in emulator

chrstdvd

Member
Does anyone know how to use vi to write script files on the Droid 2?

Specifically, I can get into vi and write a script, but I can not find out how to do the "esc" so that I can :qw (quit/write)

I can use the cat command and write small scripts that work if there are no typo's, but I need vi to edit typo's.

Thanks
 
I just use echo redirects.
There is no esc key. I could only find control -c which doesn't help with vi.
What is an echo redirect?

You can save a cat file by hitting the ok button and then d. (ctrl d)

when I hit the menu button and look at "special keys" it says that ok-] is escape, but it just types a ^] in the script. ha!
 
I just use echo redirects.
There is no esc key. I could only find control -c which doesn't help with vi.
What is an echo redirect?

You can save a cat file by hitting the ok button and then d. (ctrl d)

when I hit the menu button and look at "special keys" it says that ok-] is escape, but it just types a ^] in the script. ha!

I wrote my mount and unmount scripts by typing:

echo "blah blah blah" >> mount.sh

I did the same thing for each line that I wrote.
 
OH, DUH! Well that is cool and the same thing as doing it with the cat command but you still can not edit mount.sh on the phone in vi, because there is no way to save the changes until someone figures out a way to get back down to the command line in vi.

If I have an empty file in vi and hit "alt:" I can get to the command line and put in the commands, but once I have modified the file, it will not work.

Anyway I just tested your idea and it works fine. I have done a crash course in linux the past month and forgot about >> appending lines in a file. Cool.
 
OH, DUH! Well that is cool and the same thing as doing it with the cat command but you still can not edit mount.sh on the phone in vi, because there is no way to save the changes until someone figures out a way to get back down to the command line in vi.

If I have an empty file in vi and hit "alt:" I can get to the command line and put in the commands, but once I have modified the file, it will not work.

Anyway I just tested your idea and it works fine. I have done a crash course in linux the past month and forgot about >> appending lines in a file. Cool.

Now that I think about it, once I moved the scripts to my sdcard, I changed the extension to .txt then edited it with word.
 
I figured it out!!!

OH, DUH! Well that is cool and the same thing as doing it with the cat command but you still can not edit mount.sh on the phone in vi, because there is no way to save the changes until someone figures out a way to get back down to the command line in vi.

If I have an empty file in vi and hit "alt:" I can get to the command line and put in the commands, but once I have modified the file, it will not work.

Anyway I just tested your idea and it works fine. I have done a crash course in linux the past month and forgot about >> appending lines in a file. Cool.

Now that I think about it, once I moved the scripts to my sdcard, I changed the extension to .txt then edited it with word.

I have experimented! I just wrote a little script in the emulator on the phone that has a few echo commands in it just to see if I can execute the script after I get out of vi.

I do my typing, then hit the ok button then the c key (which is a control c), that moves the cursor to the top of the file. Then i type in ok v and I get a message on the command line that says "^v is not implemented"

Then I hit the "alt :which puts the : on the command line (gets rid of error message) and type my "wq" command which wirtes the file and quits vi.

Then I sh filename and it frigging works. COOOL! I vi'ed the file again and edited the echo statement, repeated the get out of here stuff and ran the script and it worked with the correction.

I found out that OK z exits vi but will not save what you did.:icon_ banana:dancedroid

Probably not the right way to do it, but IT WORKS. HEE HEE!
 
OH, DUH! Well that is cool and the same thing as doing it with the cat command but you still can not edit mount.sh on the phone in vi, because there is no way to save the changes until someone figures out a way to get back down to the command line in vi.

If I have an empty file in vi and hit "alt:" I can get to the command line and put in the commands, but once I have modified the file, it will not work.

Anyway I just tested your idea and it works fine. I have done a crash course in linux the past month and forgot about >> appending lines in a file. Cool.

Now that I think about it, once I moved the scripts to my sdcard, I changed the extension to .txt then edited it with word.

I have experimented! I just wrote a little script in the emulator on the phone that has a few echo commands in it just to see if I can execute the script after I get out of vi.

I do my typing, then hit the ok button then the c key (which is a control c), that moves the cursor to the top of the file. Then i type in ok v and I get a message on the command line that says "^v is not implemented"

Then I hit the "alt :which puts the : on the command line (gets rid of error message) and type my "wq" command which wirtes the file and quits vi.

Then I sh filename and it frigging works. COOOL! I vi'ed the file again and edited the echo statement, repeated the get out of here stuff and ran the script and it worked with the correction.

I found out that OK z exits vi but will not save what you did.:icon_ banana:dancedroid

Probably not the right way to do it, but IT WORKS. HEE HEE!

Nice work. You can just hit ok, c, then alt :
 
Nice work. You can just hit ok, c, then alt :

Did you already know that or just figure it out?
Anyway thanks, much simpler than the way I figured out.
 
Hey guys - good to hear u ve got vim working on ur Droid phones....

I have a DroidX which is rooted... I Would like to know where you guys got the vim binaries for the phone ? You guys built it or downloaded form some place.... Thanks....
 
Ah, now if we could just get emacs working on the droid. I've got a 32GB sdcard so it will almost fit!

Sent from my DROID2 using DroidForums App
 
Dang, just tested and that works great in vi in busybox. Excellent info.

ROX

Sent from my DROID2 using DroidForums App
 
I can not make it work on my phone anymore. I extracted busybox to /system/xbin using these instructions:
How to extract files from busybox

From terminal imulator
1. push busybox /data/local
2. mount -o remount,rw -t yaffs2 /dev/block/mtdblock3 /system
check your phone to see if you already have /system/xbin, if not type the following command
3. mkdir /system/xbin
4. cat /data/local/busybox > /system/xbin/busybox
5. chmod 755 /system/xbin/busybox
6. busybox --install /system/xbin
7. mount -o ro,remount -t yaffs2 /dev/block/mtdblock3 /system
7. sync
8. reboot

From adb on computer
source: Droid Explorer
I checked in /system/xbin to get info on vi. It says 12 dec 10 file size 1062922.

I wonder if I have a revised from the one I was using in November.

I have had to revert to typing scripts on the phone using "cat > xxx" then copying xxx to the sdcard, hooking to the computer, going into mass storage mode, then using notepad to edit my typo's ;then I have to copy the revision back to the original folder on the phone. Very frustrating!
 
Back
Top