View Full Version : [ubuntu] [SOLVED] how to quit editing and go back to cli?
pshootr
December 11th, 2008, 09:57 AM
How do I get back to cli when editing a file?
rakris
December 11th, 2008, 09:59 AM
you mean when using vim? esc+:q
Or you mean when using desktop? alt+F1 ..
Dont know what u asked
pshootr
December 11th, 2008, 10:02 AM
I am running ubuntu server 8.10 And when I am editing a file, I dont know how to exit if you will, and get back to the CLI
nhasian
December 11th, 2008, 10:04 AM
I hope your talking about vi(m) because it rules ):P
it has a rather steep learning curve but i found the vim-tutor very helpful. its not installed by default so you need to do:
sudo apt-get install vim-full
then you can start the tutor with:
vimtutor
cheers
Michael.Godawski
December 11th, 2008, 10:04 AM
What command are you using to edit the file?
for vi it is esc and
:q
enter
pshootr
December 11th, 2008, 10:08 AM
What command are you using to edit the file?
for vi it is esc and
:q
enter
/etc/network/interfaces That is how I opened the file
Kobalt
December 11th, 2008, 10:13 AM
That doens't tell us which file editor you use : which command exactly did you enter?
pshootr
December 11th, 2008, 10:21 AM
That doens't tell us which file editor you use : which command exactly did you enter?
I'm not using any editor per say. I am just booting as root in to ubuntu server with just a command line interface. Should I type in a command to get to the editor? I was just typing "/etc/network/interfaces" in the command line. Sorry for my newbness
nhasian
December 11th, 2008, 10:25 AM
that path leads to a file but to edit it you need to use a program like vi or nano with sudo.
sudo vi /etc/network/interfaces
sudo nano /etc/network/interfaces
if you just want to see what the file contains you can just use cat.
cat /etc/network/interfaces
pshootr
December 11th, 2008, 10:28 AM
that path leads to a file but to edit it you need to use a program like vi or nano with sudo.
sudo vi /etc/network/interfaces
sudo nano /etc/network/interfaces
if you just want to see what the file contains you can just use cat.
cat /etc/network/interfaces
Ok cool. Thank you very much. So when I use vi, how will I save and exit? or exit without saving?
prshah
December 11th, 2008, 10:54 AM
So when I use vi, how will I save and exit? or exit without saving?
save & exit
[ESC]:wq exit without saving
[ESC]:q!
== OR if you decide to use nano:
Ctrl+O = Save (writeOut)
Ctrl+X = Exit (eXit)
If you press Ctrl+X you will be prompted to save the changes, if any; you can choose to exit without saving or save and then exit. If you choose to save the file, you will be prompted for a new filename; if you want to use the same filename, just press enter; otherwise, type the (full path) new file name.
rakris
December 11th, 2008, 01:04 PM
:wq or :q
oldos2er
December 11th, 2008, 06:09 PM
"So when I use vi, how will I save and exit? or exit without saving?"
nano is a much simpler text editor, assuming you've never used vi(m).
decoherence
December 11th, 2008, 06:33 PM
A couple of things I've seen bite nano newbs ;)
Pressing CTRL S to save will result in a cryptic and mildly amusing message (and will not save)
Pressing CTRL Z will not undo. If you type CTRL Z out of habit, you can get back to the editor by typing the command "fg" (CTRL Z stops a program, which is different from quitting it in that you can resume where you left off... that's what the "fg" or 'foreground' command is for)
EmanresuusernamE
December 11th, 2008, 06:47 PM
IMO, until vi or vim get some kind of TUI like pico/nano, I'll still choose pico/nano over them. I like the fact that I didn't have to learn a whole new set of commands through trial and error (I had people telling me what to do when I first used it, when they weren't there I forgot the commands) there to be able to save and quit. I just looked at the bottom and did as it says. I won't deny that vi(m) is powerful in the least bit, but when I want to edit text, I just want to edit it and be done with it.
pmains
December 11th, 2008, 07:01 PM
As pointed out above, VI has a steep learning curve. It's not all that difficult, but finding a good introduction would be good.
i -- go into insert mode, starting before current character.
a -- go into append mode, starting after current character.
o -- start a new line and enter insert mode.
esc -- exit insert mode.
/abc -- search for "abc"
:%s/abc/123/g -- replace instances of "abc" with "123"
:3,5s/abc/123/g -- replace instances of "abc" with "123" on lines 3 to 5
yy -- yank (copy) current line
y$ -- yank everything from current char to the end of the line
dd -- delete and copy current line
p -- paste yanked/deleted text after current character
P -- paste yanked/deleted text before current character
h,j,k,l -- left, up, down, right
Powered by vBulletin® Version 4.2.2 Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.