LinuxQuestions.org
Help answer threads with 0 replies.
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 02-19-2012, 06:17 AM   #16
error_401
LQ Newbie
 
Registered: Feb 2012
Location: Europe
Distribution: DEBIAN
Posts: 8
Blog Entries: 17

Rep: Reputation: Disabled

Just hitting the same problem today.

Logged in remotely to a server I need to edit a file on. Starting vi works, loads the file, editing is possible.

Unable to leave vi whatsoever. Something looks wrong with the key behaviour.
Hitting "ESC" produces a

Code:
^[
instead of the expected

Code:
:
so no way to leave vi and also no way of leaving the active ssh console

Any inputs on how to deal with that?

Workaround

How to get out of vi. (Careful, this is forcing something which could leave you with unwanted outcome! I assume no resonsability whatsoever!)

Open a second console window.
Open a second ssh connection to the affected host your stuck in vi
Do the following:

First list all processes. Find the affected vi process which should be pretty much at the bottom anyway with:
Code:
ps | more
and use the "space" bar to scroll pagewise through the process list.
Then use:
Code:
kill xxxx
where xxxx is the process number of the vi command in which you are stuck to kill the vi process. You should be back on the ssh prompt. Now you can normally exit the ssh shell on both consoles.

Last edited by error_401; 02-19-2012 at 06:30 AM.
 
Old 12-09-2018, 11:54 PM   #17
Nardu
LQ Newbie
 
Registered: Jan 2017
Distribution: RHEL/CentOS
Posts: 3

Rep: Reputation: Disabled
Wink use VIM instead

Hi All,

For the lost beginners that will reach this thread, here's a suggestion.

I far prefer vim to vi to edit files. Some are just personal preference, but the winning reason is as follows.
Once you have vim installed, there is a guided practice or exercise you could use to learn how to use the editor in cli.

In cli (as sudo, if applicable) just type vimtutor and return.

This vimtutor will show you the ropes around all of the yank/put (copy/paste) commenting out, searching and all basics controls.
 
Old 12-10-2018, 01:28 AM   #18
berndbausch
LQ Addict
 
Registered: Nov 2013
Location: Tokyo
Distribution: Mostly Ubuntu and Centos
Posts: 6,316

Rep: Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002Reputation: 2002
Quote:
Originally Posted by lommer0 View Post
Btw, this kind of super-newbie information should maybe be put in man pages? maybe a section of the man dedicated to newbs? Just so that people might have some idea where to start...

this also applies to exiting man pages I figured out too... :-)
Man pages are reference documents, not necessarily meant to be introductions.

There is enough material available on vi and vim, though. For example this very official-looking https://www.linux.com/learn/vim-101-beginners-guide-vim, or several books (some free), tutorials and other programs directly on the vim site: https://www.vim.org/docs.php.

There is even a command named vimtutor. Not sure though if it exists on your distro.
 
Old 12-10-2018, 03:23 AM   #19
YesItsMe
Member
 
Registered: Oct 2014
Posts: 915

Rep: Reputation: 313Reputation: 313Reputation: 313Reputation: 313
Quote:
Originally Posted by Nardu View Post
For the lost beginners that will reach this thread, here's a suggestion.

I far prefer vim to vi to edit files.
That will not really help lost beginners, since Vim uses similar commands as vi, including the exit. But yes, once you're in vimtutor (which is basically Vim with a help file in a buffer), it will tell you how to get out.
 
Old 12-10-2018, 07:30 AM   #20
ehartman
Senior Member
 
Registered: Jul 2007
Location: Delft, The Netherlands
Distribution: Slackware
Posts: 1,674

Rep: Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888Reputation: 888
Quote:
Originally Posted by lommer0 View Post
Ok, I've been using linux on console only PC for a couple days now and one big thing is really bothering me...

How do I exit vi
For _real_ vi, use :x<enter> (save if needed and then exit), when you're using the improved vi (vim), ZZ (from visual mode) will do just the same (and it's one less keystroke).

emacs and joe I never used, so do not know.

Last edited by ehartman; 12-10-2018 at 07:32 AM. Reason: syntax error in quoting
 
Old 12-10-2018, 07:46 AM   #21
YesItsMe
Member
 
Registered: Oct 2014
Posts: 915

Rep: Reputation: 313Reputation: 313Reputation: 313Reputation: 313
Quote:
Originally Posted by ehartman View Post
emacs and joe I never used, so do not know.
Emacs: Ctrl+XC (or Ctrl+XS Ctrl+XC to save first).
Joe:
  • jpico mode: Ctrl+O (to save), Ctrl+X (to exit).
  • jmacs mode: See Emacs.
  • jstar mode: Ctrl+KX to save and exit, Ctrl+KQ to exit without any further actions.
  • joe mode: Ctrl+KX to save and exit, Ctrl+C to exit without any further actions.

Last edited by YesItsMe; 12-10-2018 at 07:48 AM.
 
Old 12-10-2018, 10:20 AM   #22
DavidMcCann
LQ Veteran
 
Registered: Jul 2006
Location: London
Distribution: PCLinuxOS, Debian
Posts: 6,142

Rep: Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314Reputation: 2314
My advice on using vi or emacs is "use nano!" — certainly for the non-professional.
 
Old 12-11-2018, 02:04 AM   #23
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
you're all aware that the OP is from 2002, right?
 
1 members found this post helpful.
  


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
difference between exit 1 and exit kushalkoolwal Programming 6 10-20-2005 03:56 PM
Exit X Risetaker2003 Linux - Software 5 09-30-2003 08:10 PM
exit X ? w00t Linux - Newbie 11 06-01-2003 08:04 PM
exit xlord Programming 7 11-03-2002 11:33 AM

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

All times are GMT -5. The time now is 07:59 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