473,799 Members | 3,210 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

vi editor eating away at my chars, namely #! in UNIX

Dököll
2,364 Recognized Expert Top Contributor
Not sure how to post this, I'll just come out with it gang...

I ran into some trouble loading certain commands using an editor called "pico editor". All was working fine and suddenly stopped responding to my commands which I'll post in a bit; which contained the characters mentioned above...

So I thought okay I'll try another editor, lo and behold, I cannot run the code there either because this editor does not like me adding #!/bin/sh, and has deleted these chars rendering the code virtually unusable.

Is there a command I need to add in order for the vi editor to accept #! in the code. pico is not working and I have since driven to the college just case it was my network, same treatement there:

Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh                 
  2. #sample shell using the if                                                                            
  3. echo "Let's create a fancy directory"                                          
  4. if [ -d unixbackup ]
  5. then
  6.         echo "directory unixbackup exists"
  7. else
  8.         echo "Looks like directory unixbackup does not exist"
  9.         echo "Would you like to create it now? (y/n)"
  10.         read x
  11.         echo $x
  12.         if [ $x = "y" ]
  13.         then
  14.                 mkdir unixbackup
  15.                 echo "Super! unixbackup directory has been created"
  16.         else
  17.                 echo "Sorry! unixbackup directory has not been created"
  18.         fi
  19. fi
  20.  
It's nothing fancy but if I could run it through the vi editor, it would be great.
What are your thoughts?

Thanks!

Dököll
Feb 17 '08 #1
5 2424
numberwhun
3,509 Recognized Expert Moderator Specialist
Not sure how to post this, I'll just come out with it gang...

I ran into some trouble loading certain commands using an editor called "pico editor". All was working fine and suddenly stopped responding to my commands which I'll post in a bit; which contained the characters mentioned above...

So I thought okay I'll try another editor, lo and behold, I cannot run the code there either because this editor does not like me adding #!/bin/sh, and has deleted these chars rendering the code virtually unusable.

Is there a command I need to add in order for the vi editor to accept #! in the code. pico is not working and I have since driven to the college just case it was my network, same treatement there:

Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh                 
  2. #sample shell using the if                                                                            
  3. echo "Let's create a fancy directory"                                          
  4. if [ -d unixbackup ]
  5. then
  6.         echo "directory unixbackup exists"
  7. else
  8.         echo "Looks like directory unixbackup does not exist"
  9.         echo "Would you like to create it now? (y/n)"
  10.         read x
  11.         echo $x
  12.         if [ $x = "y" ]
  13.         then
  14.                 mkdir unixbackup
  15.                 echo "Super! unixbackup directory has been created"
  16.         else
  17.                 echo "Sorry! unixbackup directory has not been created"
  18.         fi
  19. fi
  20.  
It's nothing fancy but if I could run it through the vi editor, it would be great.
What are your thoughts?

Thanks!

Dököll
I code in vi when using *nix all the time and have never had any issue where it removed text without me removing it. Just save the file after adding the text. Have you tried adding the text in vi and see if it happens. I don't see why a text editor would care what text you put into it. Unless it was placed in its command interface. In vi, if you hit escape -> : that puts you into command mode and if you enter something after the colon, then it would be interpreted as a command and not text.

Regards,

Jeff
Feb 17 '08 #2
Dököll
2,364 Recognized Expert Top Contributor
I code in vi when using *nix all the time and have never had any issue where it removed text without me removing it. Just save the file after adding the text. Have you tried adding the text in vi and see if it happens. I don't see why a text editor would care what text you put into it. Unless it was placed in its command interface. In vi, if you hit escape -> : that puts you into command mode and if you enter something after the colon, then it would be interpreted as a command and not text.

Regards,

Jeff
Hey Jeff, good advice!

I don't think I saved after adding the code there. Perhaps I was disoriented since pico runs a bit differently.

Will give it a whirl again, thanks Jeff!

Köll
Feb 17 '08 #3
Dököll
2,364 Recognized Expert Top Contributor
Hey Jeff, good advice!

I don't think I saved after adding the code there. Perhaps I was disoriented since pico runs a bit differently.

Will give it a whirl again, thanks Jeff!

Köll
By the way, Jeff...

Why would I get a "terminal too wide" type of an error? Now and then when I have a lot of code in the editor it seems to throw that message down below.

In a bit!
Feb 17 '08 #4
Dököll
2,364 Recognized Expert Top Contributor
By the way, Jeff...

Why would I get a "terminal too wide" type of an error? Now and then when I have a lot of code in the editor it seems to throw that message down below.

In a bit!
Please disregard the above. Looks like vi does not like the screen maximized. That's news to me.

The command now works and as mentioned vi does not delete stuff, my silly way of looking at it failed me:-)

Will be using vi more often to grab some tips.

The problem I am having now is that, I cannot remove my directory:

Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh
  2. #Sample Shell to remove directory...
  3.  
  4. echo "Let's delete a fancy directory"
  5. if [ -d unixbackup ]
  6. then
  7.         echo "directory unixbackup exists"
  8.         echo "Would you like to delete it now? (y/n)"
  9.         read x
  10.         echo $x
  11.         if [ $x = "y" ]
  12.         then
  13.               rmdir  unixbackup
  14.                 echo "Super! unixbackup directory has been deleted"
  15.         else
  16.                 echo "Sorry! unixbackup directory has not been deleted"
  17.         fi
  18. fi
  19.  
After giving myself full access to a script file containing above command through SSH Secure Shell, I get a Command not found. It was working before.

I attempted to back track, just to see if I had done something like delete the script by accident, still nothing.

What do you think may be happening?

Thanks for your help!
Feb 17 '08 #5
Dököll
2,364 Recognized Expert Top Contributor
Please disregard the above. Looks like vi does not like the screen maximized. That's news to me.

The command now works and as mentioned vi does not delete stuff, my silly way of looking at it failed me:-)

Will be using vi more often to grab some tips.

The problem I am having now is that, I cannot remove my directory:

Expand|Select|Wrap|Line Numbers
  1. #!/bin/sh
  2. #Sample Shell to remove directory...
  3.  
  4. echo "Let's delete a fancy directory"
  5. if [ -d unixbackup ]
  6. then
  7.         echo "directory unixbackup exists"
  8.         echo "Would you like to delete it now? (y/n)"
  9.         read x
  10.         echo $x
  11.         if [ $x = "y" ]
  12.         then
  13.               rmdir  unixbackup
  14.                 echo "Super! unixbackup directory has been deleted"
  15.         else
  16.                 echo "Sorry! unixbackup directory has not been deleted"
  17.         fi
  18. fi
  19.  
After giving myself full access to a script file containing above command through SSH Secure Shell, I get a Command not found. It was working before.

I attempted to back track, just to see if I had done something like delete the script by accident, still nothing.

What do you think may be happening?

Thanks for your help!
About this problem!

Well, I must be losing my marbles but I deleted my .cshrc and .longin files after making copies of them.

All is well now:-)
Feb 22 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
2819
by: Jason Tesser | last post by:
What is the best overall ide studio that can be used to develop crossplatform apps (win,linux,mac) for python? Jason Tesser Web/Multimedia Programmer Northland Ministries Inc. (715)324-6900 x3050
36
2773
by: ChinStrap | last post by:
When not using the interactive prompt, what are you using? I keep hearing everyone say Emacs, but I can't understand it at all. I keep trying to learn and understand why so many seem to like it because I can't understand customization even without going through a hundred menus that might contain the thing I am looking for (or I could go learn another language just to customize!). Personally I like SciTE, it has everything I think a...
14
8797
by: SD | last post by:
I am thinking about writing a text editor in C for unix sometime soon. I am just doing this to learn more about C. I want to write something like ed.c, a simple line editor. What types of data structures would be appropriate? I am thinking about using a linked list, but I am also wondering whether a tree would be useful. Please give me your ideas...thanks, tilak
24
1623
by: Desmond Cassidy | last post by:
Hi, I don't know whether this is the correct place to ask this question..anyway here goes... I have a large solution with about 300 .vb files split into 9 projects VB.net Framework 1.1 WinXP Pro Whilst editing, as soon as I try and enter a statement like Private strName as string
1
2016
by: google | last post by:
Hello all- Apologies to everyone for what's probably a very inchoate and uninformed question, but I've been thrust into the position about having to learn more about PHP very quickly. (I'm also posting to alt.comp.lang.php, since I'm not sure what the difference is between the two groups.) Basically, I run a Web site that includes two PHP-based subsites -- one WordPress site and one PHPBB site. I get traffic that strikes me as
63
3984
by: John Salerno | last post by:
I know there's a request for a good IDE at least once a week on the ng, but hopefully this question is a little different. I'm looking for suggestions for a good cross-platform text editor (which the features for coding, such as syntax highlighting, etc.) but not a full IDE with all the fancy jazz (GUI developer, UML diagrams, etc.). Ideally, it would be something I could even put on a flash drive and move from computer to computer, but...
19
2176
by: saurabh.ss | last post by:
I want a C++ editor for Linux that resembles Microsoft Visual Studio's integrated editor. I mean it should have features like auto-completion, auto-indentation and syntax highlighting. Also it should support windows like hotkeys like Ctrl-C, Ctrl-V. Please do not recomment vi or emacs. I know that those are best out there but it will take me some time to learn them to use them efficiently and I do not have that luxury. I am unsatisfied...
12
2026
by: sid | last post by:
Hi! I am sorry that I am asking a little off topic question, but I am sure some of you can surely help me. I am writiing a VI like text editor in C++ for the console. I would like to know some opensource tools that would help me build it faster. Also, What would be the best approach to build it? Thank You.
3
231
by: Hallvard B Furuseth | last post by:
I wrote: Okay, I've seriously miscommuniated here... If I do this, I'll reformat the code to what will become the project's new style, and commit the results. Assuming it gets OKed. When the changes quiet down we'll presumably go back to the "don't reformat unnecessarily" rule.
0
9688
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9546
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10490
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10260
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10243
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7570
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6809
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4146
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3762
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.