andrewducker: (Kitten Stalking)
[personal profile] andrewducker
So, I figured that I should get the code for my firefox addon into a version control system of some kind, and that this would be a good time to take git for a test run.

So I do a git init, and a git add ., and then when I do a git commit I am presented with this image:


At which point I enter the text I want, and have _no_ idea what to do next. Pressing "Esc" doesn't pull up anything useful, there's no help that I can see in the manual for what to do next, and frankly, this leaves me completely stymied.

I assume that what I've got there is basically some kind of unix text editor that I've been dropped into, but as I haven't used anything like that since 1992, this is less than useful.

I would just start pressing random buttons, but I'd rather not mess this up, and I believe that git is one of these things that's very easy to fuck up if you go wandering off randomly.

Anyone care to point me in the right direction?

Edit: Had help from lovely people, and then worked out how to replace the editor with one I know.

Date: 2011-05-01 11:36 am (UTC)
ext_267: Photo of DougS, who has a round face with thinning hair and a short beard (Default)
From: [identity profile] dougs.livejournal.com
Type G (case is important) to get to the end of the file.
type o (lower case) to open up a new line for typing.
type all your extra stuff.
Hit Esc.
Type :wq to write and quit.

Date: 2011-05-01 11:39 am (UTC)
ext_267: Photo of DougS, who has a round face with thinning hair and a short beard (Default)
From: [identity profile] dougs.livejournal.com
And look at the manual pages for vi(1) or vim(1), which is the editor you've been given.

Date: 2011-05-01 12:19 pm (UTC)
drplokta: (Default)
From: [personal profile] drplokta
I think [livejournal.com profile] dougs knows vi(m), but not git. The commit message should go at the beginning of the file, not the end, so ignore the first line of these instructions.

Date: 2011-05-01 12:27 pm (UTC)
ext_267: Photo of DougS, who has a round face with thinning hair and a short beard (Default)
From: [identity profile] dougs.livejournal.com
The doctor's diagnosis is quite correct, and you should rely on his instructions.

Date: 2011-05-01 11:05 pm (UTC)
From: [identity profile] khbrown.livejournal.com
:wq is the only vi command I remembered from this and thus my favourite. Emacs was a bit easier.

Date: 2011-05-01 11:38 am (UTC)
From: [identity profile] alextfish.livejournal.com
This looks like Emacs to me. The Emacs keyboard controls are indeed somewhat obscure if you're not used to them. (The other major category of Unix text editors is the VI family, Gvim and so on. Their keyboard controls are just as obscure, and holy wars are fought over which is less obscure.) There are a few useful quick-reference sheets available with a Google or two, but the controls you want are:

C-x C-s (which is Emacsese for Ctrl-x Ctrl-s): Save
C-x C-c: Quit
C-_ (Ctrl-underscore, usually Ctrl-shift-minus): Undo

There are many more. It's quite powerful once you get used to it: it has a "kill ring" which is like an indefinitely large clipboard history, and so on.

Date: 2011-05-01 11:39 am (UTC)
From: [identity profile] alextfish.livejournal.com
...And now I see the window is titled "VIM", so... yeah. That's the VI family, so go with dougs's advice. But oh well, if you ever find yourself in Emacs and don't know what to do, then the above may be useful :)

Date: 2011-05-01 11:39 am (UTC)
From: [identity profile] ajr.livejournal.com
This looks like Emacs to me.

Looks more like VI to me, seeing as it says "VIM" in the title bar and all.

Date: 2011-05-01 12:34 pm (UTC)
From: [identity profile] skington.livejournal.com
Ctrl-minus works just as well, at least in stock Debian installs of Emacs.

Date: 2011-05-01 12:20 pm (UTC)
drplokta: (Default)
From: [personal profile] drplokta
Better still, do 'git commit -am "message"', and you won't have to use an editor at all.

Date: 2011-05-01 03:07 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
That's probably vi.

It's a POS.

Glad you got help onto something decent.

Date: 2011-05-01 04:30 pm (UTC)
From: [identity profile] andrewhickey.livejournal.com
vim is very, very far from a pos. But using it to type a single-line commit message is like hiring the Royal Philharmonic Orchestra en masse because you want someone to hit a triangle.

Date: 2011-05-01 06:21 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
I don't think I've used vim. But it has the same crack-headed interface that belongs either in the 1970s or the bin -- take your pick.

Date: 2011-05-01 06:30 pm (UTC)
ext_58972: Mad! (Default)
From: [identity profile] autopope.livejournal.com
It's not crack-headed if it's wired into your fingertips and you learned to use it on a serial terminal more than 20 years ago ... Like me. Or if you want an extensible editor only barely less powerful than GNU emacs that is scriptable in languages over than lisp. And modern vim has GUI bindings so your preferred finger-macros should work -- google for CREAM and Vim.

Date: 2011-05-01 06:50 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
Just because you can wire something into your fingers does not make it sane or sensible or usable. Look at Rachmaninov.

And things like vi and emacs are just a social marker now -- you're a l33t hacker because you master them, and so vice versa. But that doesn't make them good either.

Date: 2011-05-01 07:01 pm (UTC)
From: [identity profile] andrewhickey.livejournal.com
It's definitely *not* just a social marker thing. There are a lot of features (regexes, bracket matching, editing *REALLY BIG* files) that Vim, Emacs and a couple of other editors handle better than the rest.

Date: 2011-05-01 07:09 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
Regexes and bracket matching I've certainly used on GUI editors -- TextEdit on Windows and TextMate on OS X. Whether linux has something up to that standard I don't know. Really big files -- depends how big. I have previously opened a database dump (accidentally) in TextMate and it was slow but didn't choke.

Date: 2011-05-01 11:08 pm (UTC)
From: [identity profile] khbrown.livejournal.com
Depends on which regexes you know or learned first I would say - understanding Perl regexes isn't much use in Emacs without having a copy of Mastering Regular Expressions or similar to translate between them.

Date: 2011-05-01 11:27 pm (UTC)
From: [identity profile] andrewhickey.livejournal.com
I don't actually know anything about Emacs regexes, so I'll take your word for it. (For some reason my workplace is about 90% Vi(m), 10% Emacs (if that) so I have only others' word that Emacs is as powerful as Vim).

Date: 2011-05-01 08:31 pm (UTC)
From: [identity profile] makyo.livejournal.com
... if it's wired into your fingertips ...
I started using vi about fifteen years ago, when I was working on a project on a system (a turquoise pizza-box SGI Indy) which had no other full-screen text editor installed. By the time the project finished, I was used to it (as you say, it was wired into my fingertips) and I carried on using it for preference, because I could pretty much guarantee that it would be available on any Unix-like system I was ever likely to find myself using.

Date: 2011-05-01 06:40 pm (UTC)
From: [identity profile] andrewhickey.livejournal.com
What [livejournal.com profile] autopope said. There's only so many interface options when you're creating a text editor and want it to be usable in terminal mode - Vi(m) has a far better interface than Emacs, the only real competitor (pico/nano is more intuitive, but that's because you can't do very much with it).

Date: 2011-05-01 06:44 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
When I need a terminal editor, yes, I use nano because like you said, it's intuitive and doesn't leave you stuck on a cryptic interface where you're clueless what to do.

But the only times I need a terminal editor is when I'm ssh-ing into a server and in those situations I'm firefighting, so I need only the essentials, and also in a UI that I don't have to fight.

Any other time, there are now decent, modern text editors available ;)

Date: 2011-05-01 06:56 pm (UTC)
From: [identity profile] andrewhickey.livejournal.com
See, I've spent much of the last three years working on either cut-down versions of GNU/Linux, running in a buggy emulator, sometimes on machines 6000 miles away, or hacked together versions of OpenSolaris, running in an even more buggy emulator, or development versions of AIX with unstable kernels and no X. And I have to try to get perl scripts running on these things.
When your only options are vim or ed, vim starts looking a lot nicer ;)

All you actually need to know about Vim

Date: 2011-05-01 04:36 pm (UTC)
From: [identity profile] andrewhickey.livejournal.com
[livejournal.com profile] dougs is exactly right - and his advice works for vi as well as vim, and is The Right Way. But if you ever find yourself in vim again, all you need to know is:
arrow keys work as you'd expect, as does delete.
Backspace only works in interactive mode.
To get into interactive mode and start typing, type i
To stop typing again, hit Esc
To write your changes to the file and close, once you've hit Esc, type :wq

That doesn't allow you to get particularly good use out of Vim, but it's easy to remember and does allow you to type, delete, save and quit.

Re: All you actually need to know about Vim

Date: 2011-05-01 06:40 pm (UTC)
From: [identity profile] makyo.livejournal.com
Or, to get out of it without causing any damage:
<esc>:q!<return>

<esc> puts you into command mode, : gives you a command prompt, and q! means "quit without saving or asking me about it".

Re: All you actually need to know about Vim

Date: 2011-05-01 06:46 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
Yes, and AAAAAAAAAARGH.
I can just about see that esc is a logical choice. But why the fuck a colon after that? I mean, fucking WHY? Which fuckhead designed it, really, that's what I want to know. And then, yknow, give them a good kicking.

Re: All you actually need to know about Vim

Date: 2011-05-01 08:09 pm (UTC)
From: [identity profile] makyo.livejournal.com
Unless someone's actually forcing you to use vi, then this would seem like something of an over-reaction. Perhaps there are more worthwhile things you could be channelling that time and effort into.

Re: All you actually need to know about Vim

Date: 2011-05-01 08:23 pm (UTC)
From: [identity profile] momentsmusicaux.livejournal.com
When other systems like git drop you into it, then effectively, one is forced to use it.

Re: All you actually need to know about Vim

Date: 2011-05-01 08:42 pm (UTC)
From: [identity profile] makyo.livejournal.com
Most Unix-based utilities default to vi as their full-screen editor, for the simple reason that it's pretty much guaranteed to be there, whereas things like emacs or pico might not be. Almost all such utilities check the environment variables EDITOR and VISUAL first, and use whatever they're set to, only falling back to vi in the absence of any explicit instructions. So if you set them to point to your preferred editor, then you need never have to use vi again.

Date: 2011-05-01 05:33 pm (UTC)
From: [identity profile] despotliz.livejournal.com
I was told that the best way to get a random string of text in Unix is to sit a novice in front of vi and get them to try and exit...

Date: 2011-05-01 06:25 pm (UTC)
From: [identity profile] makyo.livejournal.com
A friend of mine (the late, sadly missed [livejournal.com profile] blue_condition) once had a problem with inconsiderate colleagues remotely logging into the unix workstation on his desk, and hogging local resources (cpu, disk space, etc). So he de-installed or otherwise locked down all text editing software (including vi, ed, ex and so on) leaving only TECO available. Which only he, amongst his colleagues, knew how to use. I believe they got the message reasonably quickly.

Date: 2011-05-01 07:41 pm (UTC)
From: [identity profile] drdoug.livejournal.com
I remember that story! It's the companion in my mind to the one where [livejournal.com profile] steer ill-advisedly badmouthed vi to [livejournal.com profile] minusbat, who promptly rooted [livejournal.com profile] steer's machine and (obfuscatedly) replaced his favoured editor with a script that simply called his favoured editor six days a week, but once a week displayed the message:
friday is vi day
... and started vi instead.

Date: 2011-05-01 08:18 pm (UTC)
From: [identity profile] makyo.livejournal.com
Oh yes, I remember that one too. Apparently [livejournal.com profile] blue_condition, when told that Debra was the only one in that research group who used vi, asked "What do all the others do? Type it all in again every time?"

I believe [livejournal.com profile] minusbat was also one of the founder members of visoc (the University of York Vi Society) which was founded in order to install and maintain a clone of vi on the central VAX/VMS system. I think he mentioned they had some t-shirts printed one year, which had a load of tildes down the right-hand (that is, dexter) side.

May 2026

S M T W T F S
      1 2
3 45 6 7 8 9
10 11 1213141516
17181920212223
24252627282930
31      

Most Popular Tags

Style Credit

Expand Cut Tags

No cut tags
Page generated May. 13th, 2026 04:02 am
Powered by Dreamwidth Studios