LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 06-22-2008, 05:12 AM   #1
fm_hyudin
LQ Newbie
 
Registered: Jun 2008
Posts: 17

Rep: Reputation: 0
Question why gedit text editor doesn't work?


Hi..

Thanks in advance for reading my topic.Sorry for asking help again.

i'm having problem with gedit editor.The problem which i face is that when i type something inside the gedit editor by using command such as opening a existing file:

Code:
$ vi linux
or
vi linux
After typing these, it doesn't open the file and doesn't show any error message.Its first time i'm using these gedit editor by using command because i need to do my project.I tried by opening the file using GUI by moving the mouse and selecting, the file can be opened and it shows the content inside the file.Plz correct me if i'm wrong and plz guide me too and thanks alot for all your help.

This is my project question:

1. Open the file named “linux” in the vi editor
2. Append the following text at the new line:
Hello World!
Hello Good Morning
Hello Good Afternoon
Hello Good Evening
Hello Good Night
3.Delete 2 lines starting from the statement “Hello Good Morning”
4.Search for the entire file for the string named “Hello” and replace
each occurrence with the string, namely “Hi”
5.Save and quit the vi editor
 
Old 06-22-2008, 06:28 AM   #2
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
It isn't really clear to me what exactly you're doing. Are you trying to type commands into gedit? If so, that's wrong. All you're doing by typing stuff in gedit is, well, typing stuff. If you want to run vi, then you open a terminal window and run "vi file", where file is the name of the file you want to create.
 
Old 06-22-2008, 07:03 AM   #3
rjlee
Senior Member
 
Registered: Jul 2004
Distribution: Ubuntu 7.04
Posts: 1,994

Rep: Reputation: 76
Quote:
Originally Posted by fm_hyudin View Post
Thanks in advance for reading my topic.Sorry for asking help again.
There's on old (Chinese?) proverb: He who asks a question is a fool for a moment, but he who does not ask is a fool for the rest of his life.

As fm_hyudin says, gedit is a text editor, in the same way that vi or emacs is. It sounds like you want to use vi, so you want to start with a terminal program, like gnome-terminal (usually under "Terminal" in the accessories menu).

It is also just possible that, when you start vi, you get a window opening labelled "gedit"? If so, then you have an alias set to run gedit instead of vi. You can run
Code:
alias
to see what aliases are in place. In this case, you may want to make sure that vi is installed and turn off the alias by running:
Code:
unalias vi
 
Old 06-22-2008, 09:17 PM   #4
chrism01
LQ Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Rocky 9.2
Posts: 18,359

Rep: Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751Reputation: 2751
And, as it happens, on Linux vi is usually symlinked to vim (vi improved) ... just fyi.

In vi/vim, its

vi filename - to edit a file, inc create a new one

press the 'i' key to go into edit/insert mode

type in your lines as described

Press 'Esc' button to get out of insert mode, into cmd mode

type the following to go to desired line

:2

then this to delete 2 lines

2dd

global search and replace

:%s/Hello/Hi/

exit & save

:x

easy
 
Old 06-23-2008, 06:36 AM   #5
fm_hyudin
LQ Newbie
 
Registered: Jun 2008
Posts: 17

Original Poster
Rep: Reputation: 0
@ Nylex

Thanks alot mate for clearing my doubt.No wonder i don't get any reply or error when typing those commands.I really understand now that i did a big and careless mistake.I'm really new to this text editors.So i thought gedit can be used.Sorry for giving problem.

@ rjlee

Yeap.I'm agree with u mate.If i didn't ask this question now, i will be fool for the rest of my life because this thing was confusing and just like u said. Gedit also is a text editor like emacs and vi.So i thought gedit can be used,Thanks alot mate for clearing my doubt and helping me.I really understand now and i really appreciate your help.

@ chrism01

Wow.Thanks alot mate.You really made my day.Thanks alot again.I really appreciate your help.I will be using your answer as my guide mate.By referring to this, it shall help me to make me learn from mistakes and my foundation stronger.Thanks alot again and i really appreciate your help.

@ Nylex & rjlee & chrism01

Thanks alot everyone for your kindful help.I really appreciate it.Thanks alot again.Its really glad to see all of you helping me.Sorry for giving problems and for any inconvenience.I learnt alot from this forum due to my mistakes and it had made my foundation in linux become stronger a bit now.God bless you all.
 
Old 06-23-2008, 08:52 AM   #6
Nylex
LQ Addict
 
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464

Rep: Reputation: Disabled
"Alot" is really two words (see link in my signature).
 
Old 06-23-2008, 09:02 PM   #7
fm_hyudin
LQ Newbie
 
Registered: Jun 2008
Posts: 17

Original Poster
Rep: Reputation: 0
Hi..

I tried typing like these to open my file using vi editor:

Code:
vi linux
then a error showed like these.

http://www.jettmedia.com/files/4azhn00ukzd19pkpb7de.png


so i just ignored the error because i don't understand what it is exactly and start pressing enter button.after that, my file opened itself.so then i got stucked again.

my question:

Append the following text at the new line:
Hello World!
Hello Good Morning
Hello Good Afternoon
Hello Good Evening
Hello Good Night

the file linux look alike:

http://www.jettmedia.com/files/dy2146va7fslejd2y6j1.png

where should i start typing those text plz.


chrism01 said:
press the 'i' key to go into edit/insert mode

type in your lines as described

Press 'Esc' button to get out of insert mode, into cmd mode

type the following to go to desired line.


plz guide me.thanks a lot for all your help.god bless.
 
Old 06-24-2008, 10:41 AM   #8
fm_hyudin
LQ Newbie
 
Registered: Jun 2008
Posts: 17

Original Poster
Rep: Reputation: 0
plz help......
 
Old 06-24-2008, 10:49 AM   #9
saikee
Senior Member
 
Registered: Sep 2005
Location: Newcastle upon Tyne UK
Distribution: Any free distro.
Posts: 3,398
Blog Entries: 1

Rep: Reputation: 113Reputation: 113
Nobody can help a person who doesn't read.

Inside vi

Your press "i" to insert any text
Your press "esc" key to finish the insertion
Your press :w to write the file thereby saving it
Your press :q to quit

Also you seem to edit a swap file as warned by the kernel. What you should have done is to create a text file first, like "vi anyfile", opted to save it, quited and then do the project work.

A swap file or a binary file is in machine code and has unprintable characters. They should never be edited.

Last edited by saikee; 06-24-2008 at 10:55 AM.
 
Old 06-24-2008, 11:36 AM   #10
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,702

Rep: Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896Reputation: 5896
swp are temporary files created by vim just like ~files in other applications. Most likely vim was exited abruptly and changes were not saved. Close vim and delete the file using the rm command.

You can search the web for vim tutorials, documentation and command cheat sheets which will answer your questions and provide additional help to what has already been provided.

http://www.tuxfiles.org/linuxhelp/vimcheat.html
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Is gedit the best for text editing? zensunni Programming 9 03-10-2008 04:12 PM
Gedit has no Text encryption Plugin yeehi General 0 11-09-2007 09:45 AM
vi editor in text mode, no x server installed, backspace don't work isuck@linux Linux - Software 2 01-27-2007 06:10 PM
Nautilus and Gedit fail to open text files zarkon Linux - Software 3 04-06-2005 10:00 AM
Text selection problem with Gedit liaohaohui Linux - Software 0 11-18-2004 04:18 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 11:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration