LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-21-2002, 07:36 PM   #1
Goatdemon
Member
 
Registered: May 2002
Location: The good 'ol USofA
Distribution: ArchLinux - Slackware 8.1
Posts: 398

Rep: Reputation: 30
Editing files at command line


how do you edit, save then close files at the command line. I want to edit my xf86config file but dont know how.
 
Old 07-21-2002, 07:46 PM   #2
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Debian + Ubuntu
Posts: 4,358

Rep: Reputation: 57
Well, that all depends on which editor you're using.

Since I generally use emacs when at the command, I'll explain that (although these are all in docs elsewhere... such as TLDP).

You start editing the file by typing emacs filename. You move around the file with the arrow keys. You edit by, erm, editing. Just delete and type. You exit by typing <CTRL>+<x> and then <CTRL>+<c>. Note that these are small x and small c. You will then be prompted as to whether you want to save the file before exiting (down on the bottom line of the screen). Just press y and then hit <enter>. You should now be back at the prompt. Viola, you've just edited your first file.

Many people prefer to use vi because of its low overheads and the fact that once you've become used to the way of issuing commands (and such), you can do all your business remarkably quickly. Personally, I'm a creature comforts kinda-guy, so I don't like to make things to difficult on myself.

There has been many a flamewar over vi/emacs, and I don't intend on starting one here. I hope that anyone else who is inclind to give a quick tutorial on basic editing with their favourite editor (although it seems that most are fairly similar) does so.

Hope this helps (and I like your sig).
 
Old 07-21-2002, 07:48 PM   #3
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974Reputation: 1974
pico
pico
pico
pico
 
Old 07-22-2002, 12:19 AM   #4
Ryan_Sutton
Member
 
Registered: May 2002
Location: California
Distribution: Fedora 9
Posts: 101

Rep: Reputation: 15
I like vi although I don't really have a good reason, I just use it.

to use #vi file

once in vi press "a" to insert text after the cursor, once you have what edited the file, press the 'esc' key and then type ":wq!" to write the file and exit.
 
Old 07-22-2002, 12:52 AM   #5
neo77777
LQ Addict
 
Registered: Dec 2001
Location: Brooklyn, NY
Distribution: *NIX
Posts: 3,704

Rep: Reputation: 56
And I prefer vi for its simplicity sort of, to save and quit just press Esc and then Shift-Z-Z (meaning press z letter twice while holding shift key), it is much quicker than typing :wq
 
Old 07-22-2002, 01:04 AM   #6
Ryan_Sutton
Member
 
Registered: May 2002
Location: California
Distribution: Fedora 9
Posts: 101

Rep: Reputation: 15
hey thx for that tip neo!
 
Old 07-22-2002, 06:49 AM   #7
RefriedBean
Member
 
Registered: Jun 2002
Location: N 37 33.327 E 126 55.650
Distribution: Gentoo, Slackware, OpenZaurus
Posts: 186

Rep: Reputation: 30
Quote:
Originally posted by acid_kewpie
pico
pico
pico
pico
W00t!!
pico rocks
 
Old 07-22-2002, 10:57 AM   #8
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
Like I always say and I'll say again.. Try to learn vi, every good *nix Admin knows vi, cause at times it might be the only way to edit files..

So I assume I prefer vi as well.
 
Old 07-22-2002, 02:49 PM   #9
jglen490
Member
 
Registered: Apr 2002
Location: The next brick house on the right.
Distribution: Kubuntu 8.04
Posts: 668

Rep: Reputation: 31
As was previously noted, it depends on your choice of editor. And you do have a choice, just like anything else in Linux.

If you are not a UNIX/LINUX administrator, then choose an editor that suits you. My personal favorite is jed (and its X counterpart, xjed). It doesn't require a whole lot of remembering, since it has a "tool" bar of function keys as reminders. Nothing against vi, it just strains my brain, since I am not an admin (except my own desktop replacement lappy) and don't very often edit system files, data files, or other text files from the command line.

I've learned "barebones" vi, and can get by, but it is not my fave. I've tried joe, and it's not bad, but it requires remembering keystroke combinations that literally go back to DOS level file editors and to Wordstar. And there are others like ed, ted, and others.

Note the complete lack of mention of the editor that comes with its own operating system (close enuff anyway!!). As a simple text editor, forget EMACS.
 
Old 07-22-2002, 02:56 PM   #10
trickykid
LQ Guru
 
Registered: Jan 2001
Posts: 24,149

Rep: Reputation: 234Reputation: 234Reputation: 234
I didn't say you have to use it for your personal favorite, I just mentioned its good to know for those emergency situations when its the only editor available
I just personally prefer it cause to me its fast and easy to use, once you get use to it.

But yeah, there are so many editors out there. Might as well use pico though so Acid doesn't get mad at your for not using it..
 
Old 07-25-2002, 12:09 AM   #11
Aussie
Senior Member
 
Registered: Sep 2001
Location: Brisvegas, Antipodes
Distribution: Slackware
Posts: 4,590

Rep: Reputation: 56
Two words...Midnight Commander.
 
Old 07-26-2002, 04:45 PM   #12
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
you can always try editing the inodes by hand with a magnet...
 
Old 07-26-2002, 04:49 PM   #13
jglen490
Member
 
Registered: Apr 2002
Location: The next brick house on the right.
Distribution: Kubuntu 8.04
Posts: 668

Rep: Reputation: 31
Right you are, trickykid !!
 
Old 08-11-2002, 07:19 PM   #14
xylum
LQ Newbie
 
Registered: Aug 2002
Posts: 13

Rep: Reputation: 0
guys i keep getting an error thats says read only how do i change it so i can edit this file. oh i'm talking about the xf86config-4 file.
 
Old 08-11-2002, 08:19 PM   #15
Thymox
Senior Member
 
Registered: Apr 2001
Location: Plymouth, England.
Distribution: Debian + Ubuntu
Posts: 4,358

Rep: Reputation: 57
man chmod... it depends on what write options you want to give it! Oh, and to edit the XF86Config-4 file, you'll need to be root, so man su as well.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Command Line Image Editing fractal_chaos Linux - Software 8 10-03-2005 06:33 PM
scheme interpreter w/ command-line editing nazdrowie Programming 1 12-03-2004 09:20 AM
vi style command line editing in gnuplot 3.7 sirclif Linux - Software 0 09-20-2004 01:47 PM
editing XF86Config from command line flum Linux - Newbie 4 09-10-2003 05:12 PM
command line editing eddcrossman Linux - Newbie 7 02-16-2003 08:37 PM


All times are GMT -5. The time now is 10:32 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration