Scripts based on vi


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Scripts based on vi
# 1  
Old 10-30-2010
Scripts based on vi

since no one can give me mapping or scripts to make vi easier
I'm thinking about writing some for it.

But first I need some help (hopefully this one will be answered)
1) How do I execute scripts based on user action
ex.
user press ctrl+h I let him insert stuff and then making a search based on what he wrote
or
user press the arrow -> before end of line (last char) or the opposite and instead of going into command mode it will do the command a/i/o/O
2) How do I execute scripts based on user position in file
ex.
user gets to end of line in the text editor script runs...
or
user is not in end or start of line I start a script
(I want to know where the user is in the file and make adjustments for that)
3) Can I activate in vi coloring (like in Visual studio)?
4) Does vi have the auto completion button? (ctrl+p)

Thanks in advance!
# 2  
Old 10-30-2010
Maybe all that sort of energy went into emacs! I turn most vi features off so I do not have to figure how to turn them on again if I am using vi elsewhere where the options do not exist or are turned off. Have you learned all the vi/ex tricks already? You could run eclipse, it has nice colors in the editor and is open and free, and even has C/C++ plugins. Since vi is a general editor, it is a matter of opinion what colors might be appropriate.
# 3  
Old 10-31-2010
you did not answer my questions, and I already told you that I can only use vi in my course...
and you tell me to go to use a different editor? you didn't even answer one of my questions.
# 4  
Old 10-31-2010
Check out vim, it may do some of the things you require.
# 5  
Old 11-01-2010
Well, if it is a professor-problem, then play with the ex/vi options on those man pages and other online references to see what you can do. Either ex or vi can be drive by canned scripts into stdin. I have done it, using tools like "diff3 -e" to generate the file with all the changes of two different mods of an original (I think of it as the 4th corner of a square, given zero changes, zero + x changes and zero + y changes, create the file with zero + x + y changes. It helps if you use lots of lines when writing code, not being a one line showoff. Parallel development on a budget.)

Take a tip from diff3/diff -e: the line numbered modifications are created in descending line order, so the line numbers "ahead" are not changed by the mods already applied. You can pull, modify or add the diff/diff3 -e generated mods, as long as you preserve descending line order.

When using :commands, you are essentially in ex not vi. This is more likely useful when scripting, and a good start toward learning sed and ksh command line editing.

Beware that for big files, g and v line deletions can be a quadratic or n-squared sort of problem, as g/xxx/d deletes mean the entire file is reworked with for each hit. Sometimes it is better to grep out the lines you want into a new file, or just move them within the file, like to $ = the end ( g/xxx/m$ ). ex/vi seems to do this without reorganization! Smilie
# 6  
Old 11-03-2010
Quote:
since no one can give me mapping or scripts to make vi easier
Re-mapping keys for "vi" is about your environment. We know nothing about your environment.
https://www.unix.com/unix-dummies-que...s-scripts.html

Hopefully by now you will have read up on the subject.
# 7  
Old 11-03-2010
vi is an interactive tool, not a batch tool, so it is a bad choice for what is normally the target of "scripting": unattended batch/cron/deamon activities. But perhaps all you want is keyboard mappings to some macros.

Barring a educational requirement, or antique code restoration like a Deuce Coupe 327 V-8 softtop, if I wanted to go super-custom, I'd start with emacs, at least. And really, I would start with a free IDE intended for many extensions to fit your needs.

But I don't, because as I travel, sommunicate, teach, do prod support, I have to use the stock product. The more you customize, the less capable you are without your mods, with fewer macros stored in your noggin.
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Executes scripts parallelly based on their success

Hi Team , I have one Master.sh file which call X,Y,Z scripts , but here X may call again some sub scripts X_sub1.sh , X_sub2.sh Y calls Y_sub1.sh,Y_sub2.sh and similarly Z script also . Now requirement is Both X and Y should execute parallel bcz X and Y are independent... (9 Replies)
Discussion started by: chandini
9 Replies

2. Shell Programming and Scripting

Calling multiple scripts from another scripts

Dear all, I am working on script which call other shell scripts in a loop but problem is from second script am not able to come out. Here is the snippet:- #!/bin/bash HSFILE=/root/Test/Components.txt LOGFile=/opt/domain/AdminDomain/application/logs... (3 Replies)
Discussion started by: sharsour
3 Replies

3. Shell Programming and Scripting

Script which takes two inputs based on that execute othe scripts

Hi, I am using solaris 10 bash shell.this might a small script but i am not much familiar with scripting. My requirement here is script should prompt for users two opions like this "please select either any one option makefile or make& build file". if the user selects make file option... (2 Replies)
Discussion started by: muraliinfy04
2 Replies

4. Shell Programming and Scripting

KSH - How to call different scripts from master scripts based on a column in an Oracle table

Dear Members, I have a table REQUESTS in Oracle which has an attribute REQUEST_ACTION. The entries in REQUEST_ACTION are like, ME, MD, ND, NE etc. I would like to create a script which will will call other scripts based on the request action. Can we directly read from the REQUEST_ACTION... (2 Replies)
Discussion started by: Yoodit
2 Replies

5. Shell Programming and Scripting

Running Multiple scripts based on file size.

Hi, I have created 3 shell scripts which has to run one by one first two shell scripts will create a .txt files...which are used by the third shell script.Now I want to create a master script and run all these in a single script. Please give a pseudo code on how to so the same. ... (4 Replies)
Discussion started by: gaur.deepti
4 Replies

6. Shell Programming and Scripting

calling 'n' number of shell scripts based on dependency in one shell script.

Hello gurus, I have three korn shell script 3.1, 3.2, 3.3. I would like to call three shell script in one shell script. i m looking for something like this call 3.1; If 3.1 = "complete" then call 3.2; if 3.2 = ''COMPlete" then call 3.3; else exit The... (1 Reply)
Discussion started by: shashi369
1 Replies

7. Shell Programming and Scripting

Changing the Bash Scripts to Bourne Scripts:URGENT

Hi, I have to write a program to compute the checksums of files ./script.sh I wrote the program using bash and it took me forever since I am a beginner but it works very well. I'm getting so close to the deadline and I realised today that actually I have to use normal Bourne shell... (3 Replies)
Discussion started by: pgarg1989
3 Replies

8. UNIX for Dummies Questions & Answers

Profile scripts versus rc scripts....

what is the difference between login and profile scripts versus the rc scripts? (1 Reply)
Discussion started by: rookie22
1 Replies

9. Shell Programming and Scripting

Time based Processing of the Scripts

Any one can tell me how can i execute the processes for every 10 min.Actually iam having 3 Processes for every 10 min i want to run these 3 Process,one process at every 10 min. If any of the process is busy i just want to execute the free one. first 10 min execute P1 next 10 min execute P2... (3 Replies)
Discussion started by: krk_555
3 Replies

10. Shell Programming and Scripting

Need a simple file based utilty for shell scripts

Hello, I'm wondering if you may know of a simple file based UNIX utility that can be used to store and retrieve values on a flat file, let's say i have a file called "kru", i'd like to be able to specify a request like: while(....) if ; then kru.fld2 = $rec_cnt kru.fld3 =... (4 Replies)
Discussion started by: bobk544
4 Replies
Login or Register to Ask a Question