LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   why gedit text editor doesn't work? (https://www.linuxquestions.org/questions/linux-general-1/why-gedit-text-editor-doesnt-work-650855/)

fm_hyudin 06-22-2008 05:12 AM

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

Nylex 06-22-2008 06:28 AM

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.

rjlee 06-22-2008 07:03 AM

Quote:

Originally Posted by fm_hyudin (Post 3191669)
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

chrism01 06-22-2008 09:17 PM

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 :)

fm_hyudin 06-23-2008 06:36 AM

@ 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.

Nylex 06-23-2008 08:52 AM

"Alot" is really two words (see link in my signature).

fm_hyudin 06-23-2008 09:02 PM

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.

fm_hyudin 06-24-2008 10:41 AM

plz help......

saikee 06-24-2008 10:49 AM

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.

michaelk 06-24-2008 11:36 AM

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


All times are GMT -5. The time now is 03:44 PM.