Wikipedia:Reference desk/Archives/Computing/2011 February 21

From Wikipedia, the free encyclopedia
Jump to: navigation, search
Computing desk
< February 20 << Jan | February | Mar >> February 22 >
Welcome to the Wikipedia Computing Reference Desk Archives
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages.


February 21[edit]

becoming a Unix hacker: Vi[edit]

I'm trying to become a Unix hacker, so I'm learning Vi as part of it. I have a few questions:

  • Why are the cursor keys backward for me: The "cursor" keys hjkl, go: left, DOWN, UP, right, instead of how it should go (left UP, DOWN, right). It gets me every time. Obviously up is like left, and not down is. What is the logic to it, and can I change it to be normal? Also the real cursor keys just insert gobledegook like D and stuff.
  • Why isn't there any indication whatsoever of whether I'm in insert or edit mode? I understand that Vi was made in the days when updating a single character on the terminal screen you were using at home meant the computer would dial 0, you would have to ask to ask the operator to patch you through to the University, you would have to ask the University operator to patch you through to the computer department, and then you would ask a typist to update your screen or something. So, that's why there are all these buffer tricks and hardly any updating. But, when it's all local on my own machine, shouldnt I have some means of knowing which mode I'm in?
  • Do real Vi users get confused, or does it become real easy to keep track of which mode you're in after a while? Every time I switch back to Vi from another application, I press escape three or four times, then "i", before I start typing. I can't just press "i", you see, because sometimes that would just type an 'i', which I would have to switch back to edit mode to fix, but it takes a long time, because I would end up moving down or up instead of left to fix it, etc. How are you supposed to remember whether you left your vi in edit or insert mode half an hour ago?
  • In NEITHER edit NOR insert mode will it let me add to the right-hand part of a line. So, if a line reads "i++" and I want to add the missing semicolon, I can't get any farther right than the +. I have two choices. I can insert here: i+;+ then go i+;x+ as I try to use x to delete it, forgeting I'm in insert mode, then I'm in edit move but have moved four or five lines away by hitting the wrong "cursor" key, so I make my way back meticulously and use "x" to get rid of the "x", and the "+". Now I have "i+;" and there's just one more step: putting in the missing +. So, I go off in the wrong direction with the cursor keys again, then finally make it back, press escape a few times, press i, and then insert the missing "+". Overall, every time I have to add to the end of a line, it takes me about 30 seconds.
  • When I switch from insert to edit mode, it's a gamble what pressing "x" will delete. How do I figure it out?

Those are the major questions I have, for the rest I'm being a good boy and trying to refer to documentation. So far, I have spent about an hour and a half fighting vi - and all I'm doing is copying, by hand, a code sample from a web site (obviously, given my experience with the cursor keys, I'm not about to try to find out what ctrl-v would do). I can't imagine how things will get when I have to do my own editing. 109.128.201.187 (talk) 00:27, 21 February 2011 (UTC)

I also, this was rather foolhardy, but I tried pressing the "insert" key on my keyboard to see if it would toggle between insert and overtype mode. I did not realize that vi interpreted this as meaning it had to toggle the middle of a variable from a lowercase to a capital letter, thankfully it only cost me ten minutes to figure it out. The only times I've ever had a user experience like this was when the memory of an application I was using on Windows got really badly corrupted. Right before it crashed, it would give me this same type of user experience, down to inserting weird characters for no reason and jumping around the screen and doing other weird stuff as I typed (obviously, in vi, because I was in the wrong mode). 109.128.201.187 (talk) 00:38, 21 February 2011 (UTC)
See Arrow keys#HJKL keys. To add to the end of a line, hit A (for "append") and it'll jump to the end of the line and go into edit mode there. -- Finlay McWalterTalk 00:41, 21 February 2011 (UTC)
Or for the append, do 99la (that's lowercase L). That means "move 99 chars to the right then append here"; 99l will move you to the end of a line (that's got fewer than 99 chars; for really long lines 999 etc.) Note that if your terminal is set up properly, the keyboard's normal arrow keys should work fine (as a modern VI is fully termio aware). -- Finlay McWalterTalk 00:46, 21 February 2011 (UTC)
Actually my bad - arrow keys in edit mode do insert wonky chars. -- Finlay McWalterTalk 00:55, 21 February 2011 (UTC)
Let me ask you guys, honestly. Are you Unix hackers? And still, after all these years of using vi every day, this confused? As for "if your terminal is set up correctly" or if it's a "modern" vi. I guess no to both - I mean, it's only the default full desktop install of Debian 6.0, which I downloaded, assured it would be the latest and greatest, direct from Debian's site a few days ago - I didn't change a thing. I know they're 31337 Unix hackers too, because "vim" isn't installed, only vi is. But who would want to move around in edit mode anyway? You're in an editor to type, not to dick around. Typing "991A" is a helluvalot faster than what I've been doing in vi. I guess I'll have to have a very long beard before I learn why pressing the right - not arrow key, but right "cursor key" (from hjkl) at the end of the line doesn't have that behavior. I mean, what kind of a twisted mind would it take to think "if someone is going to want to insert something in a line, obviously it will be before the last character. Why would anyone insert anything after the last character in a line? How could the last character POSSIBLY not already be the one that belongs at the end?" I tell you guys, I am in wonderland, and vi is the hatter. 109.128.201.187 (talk) 01:02, 21 February 2011 (UTC)
vi is still proprietary. On most UNIX-like systems, vi is aliased to some variant of vim, which is open source. Yes, in insert mode you can't do much except insert, and yes, characters that aren't in 7-bit ASCII give undefined results. If you're confused about which mode you're in (most vims will tell you on a status line), just hit ESC. If you're in insert mode, this will take you to command mode; if you're in command mode it won't do anything. I'm sure a little Googling will find you a command list (pretty much every key does something in command mode) that will save you time over random bashing. PhGustaf (talk) 01:17, 21 February 2011 (UTC)
Your "vi" is probably really ViM, which is plenty modern. I use vi only if I'm doing small edits in a restricted environment (that's pretty much as root editing config files). For almost everything else I use emacs. In times of yore I wrote pretty large projects entirely in vi (real, Bill Joy vi), and you get used to it (but I was no expert); there's plenty worse than vi (e.g. VMS ed, DOS edlin, HP's PAWS-ed). I'd personally recommend emacs in X windows. -- Finlay McWalterTalk 01:19, 21 February 2011 (UTC)
That's an intriguing possibility. But I tried typing "vim" and it didn't open vim, so that would be rather bizarre. Still, whereis vim shows it's SOMEWHERE. How could I tell if I'm typing in vim or vi? Perhaps it will help if I assure you that there is absolutely no status line that tells me what mode I'm in. 109.128.201.187 (talk) 01:49, 21 February 2011 (UTC)
For HJKL: This confused me too when I was first learning vi, until I saw that the letter J, if you squint, looks a little bit like a down arrow. That helped me to remember that J means down and K means up. After a while it became second nature, and now I don't have to think about it. For insert mode: If you're not sure whether you're in insert mode or not, press Esc a few times, and then you'll know you're not in insert mode. But this is something else I learned to keep track of subconsciously, so I don't get confused about it very much any more. —Bkell (talk) 01:14, 21 February 2011 (UTC)
About your comment about inserting after the last character in the line: There are (at least) two different ways to enter insert mode. The first is "i", for "insert," which means "enter insert mode and start inserting before the current character," and the second is "a", for "append," which means "enter insert mode and start inserting after the current character." So, if you are trying to insert after the last character in the line, you want to position the cursor over that character and press "a" to enter insert mode, not "i". These commands also have capital-letter equivalents: capital "I" means "enter insert mode and start inserting at the beginning of the current line," and capital "A" means "enter insert mode and start inserting at the end of the current line." So usually if you want to add something to the end of a line the easiest thing to do is just to type "A" rather than laboriously moving the cursor all the way to the end of the line first. —Bkell (talk) 01:22, 21 February 2011 (UTC)
For your specific problems, I would first look at your terminal configuration. All the times I've used vi/vim recently, there has been a clear indication of "-INSERT-" on the last line of the screen and the keyboard's proper arrow keys have worked as one would expect in both command and insert mode. You setup is obviously wrong somewhere unless you are using a very, very old old system or a very, very old console terminal program.
Like Finlay, I only use vi for tiny jobs or when I have to - vi's one advantage is you can pretty much guarantee it is installed on any *nix system. In my opinion, vi's major shortcoming is its command interface - honestly, who the hell thought HJKL are good cursor keys when all keyboards since at least the early 80s have had perfectly good dedicated arrow keys. I suggest you instead learn the basics of vi for the rare occasion when you need to use it, and use a proper editor for everything else. Incidentally, if you think knowing vi will make you a hacker, then you have a lot to learn. Astronaut (talk) 05:17, 21 February 2011 (UTC)
"if you think knowing vi will make you a [1337 Unix] hacker, then you have a lot to learn" - on that point, my friend, you are very mistaken. 109.128.201.187 (talk) 12:21, 21 February 2011 (UTC)
I'm an emacs user, but I think that hjkl is fine; I picked it up from playing Roguelikes, and I think that it makes more sense than using emacs's (Ctrl+) bnpf, which are at random locations on the keyboard. In general, I like emacs better, though. Paul (Stansifer) 17:06, 21 February 2011 (UTC)
A few notes: first, Debian has many versions of vi available; the only one not classified as "optional" is vim-tiny, which as its name suggests is missing a lot of the advanced features. When multiple vi packages are installed, the one that is linked to by the plain command "vi" (/usr/bin/vi) is chosen by the alternatives system (there's a command update-alternatives --config vi). Try a :version command to see which vi you're currently in. Second, showing the current mode in the status line is activated by the "showmode" option (:set showmode) and has been in vim, nvi, and the proprietary/SysV/"real" vi for a long time. Third, the menomnic I was given for hjkl is that the lowercase j and k have a descender and ascender respectively. Fourth, the insert key is an unreliable key because it sends an escape sequence that depends on the terminal type. It wouldn't hurt to send a bug report for whichever terminal you were using; making the terminal emulators and the editors and the terminal database agree with each other is the sort of thing Debian package maintainers are supposed to do and they've obviously messed this one up. But when you're good with vi you'll never use those keys. Reaching all the way over there is a waste of time when all the same functionality is right under your fingers already. Finally, vi is the proper editor. ed is the one you learn for emergencies.
Oh... and x in command mode deletes the character under the cursor. X deletes leftward. That should be easy enough. 67.162.90.113 (talk) 06:30, 21 February 2011 (UTC)
I'm a 20-year vi user and wouldn't program without it. That said, you might like to use something more beginner-friendly if you're trying to learn programming at the same time. Vi is just a tool and if it's taking up more of your thoughts than the software is, it might be best to try something different. You can always switch to vi when you find your thoughts are going faster than your hands and you want an editor that can keep up. --Sean 20:41, 22 February 2011 (UTC)

YouTube doesn't work in Safari[edit]

I'm using Safari 5.0.3 on OS X 10.6, and for the past week or so, YouTube videos have just been appearing as an empty black box. They play fine when they're embedded on other sites, but they're unwatchable at youtube.com. Clearing cookies has not fixed it. Any ideas? --140.232.176.191 (talk) 07:10, 21 February 2011 (UTC)

There are discusions about the problem here.Forum -Safari for Mac --Aspro (talk) 12:23, 21 February 2011 (UTC)

iPhone un-shuffles[edit]

I'm not sure if this problem is specific to the iPhone 4 or happens on other iOS devices. Whenever I'm listening to my music in a certain playlist, I hit "Shuffle" at the top of the song list and continue on with my day. Occasionally, however, the music becomes "unshuffled." I'll start to hear several songs from the same artist or same location in the playlist (for example, after 15 songs have played), and when I check, it's playing song "256 of 700" instead of "16 of 700," and the shuffle icon is grayed out. I can't pin down if any actions I take trigger it. I've seen no mention of this anywhere else. Anybody know what's going on?--The Ninth Bright Shiner 15:09, 21 February 2011 (UTC)

Help me with Craigslist, please. Also, what great alternatives are there that are like CL?[edit]

This is my job ad posted to their site: http://ksu.craigslist.org/edu/2218478487.html

However, it doesn't show up on the list it's supposed to be on: http://ksu.craigslist.org/search/edu?query=+

It's still green, so still active. Why won't it show up on the list if active?

Moreover, does Craigslist have a realtime chatroom anywhere? Forums are inherently slower in responses.

Besides, since the Craigslisting isn't turning up any results, what are some great Craigslist alternatives to post free job listings at, that anyone within the Manhattan, KS area will still see? --129.130.98.164 (talk) 18:55, 21 February 2011 (UTC)

Have you tried non-online options? My suggestion would be to put up some fliers in places where people who have taken that class (e.g. majors in the same department, or graduate students) will find it. You can be much more specific in targeting your audience than Craigslist in this case, since you can reasonably guess where said people might be found. --Mr.98 (talk) 19:13, 21 February 2011 (UTC)
(ec) I know that the CL search engine takes a little while to update. CL doesn't have online chat, but its forums move pretty fast. You should probaly also look for job or tutoring boards within KSU itself, including physical noticeboards (the kind where you write your ad on a slip of paper and attach it to the board) within the communications department. You could also ask the department secretary or one of your instructors if they can refer you to any tutors. I'm really surprised you're having trouble getting help, since at any university there are always LOTS of students trying to pick up a bit of $$$ by tutoring. You might also drop the requirement that the tutor have actually taken that particular class. At least at my school, tutors were often graduate students who had the relevant knowledge to help with the class, but had done their own undergraduate classwork elsewhere. 71.141.88.54 (talk) 19:17, 21 February 2011 (UTC)
Did you respond to the e-mail that the Craigslist robot sent you? Maybe that's why it doesn't show up in searches? Since this is now 5 days old, I'd start again from scratch, by the way. I agree that physical postings around the school are a good idea. Comet Tuttle (talk) 19:19, 21 February 2011 (UTC)

Will a USB harddrive meant for Windows also work for Ubuntu?[edit]

The (500GB) harddrive has a USB 3.0 connection and NTFS file system. The sticker on the packaging says it is for Windows and does not mention Ubuntu at all. Will it work on Ubuntu too? —Preceding unsigned comment added by 20:01, 21 February 2011 (UTC)

I would be very surprised if it didn't. USB is a standard interface that's supposed to work everywhere: that's what the U means. Marnanel (talk) 20:08, 21 February 2011 (UTC)
Linux has had USB 3.0 support since kernel 2.6.31 (September 2009); Ubuntu currently provides 2.6.35. Officially Windows 7 won't have its own support until SP1, although you can use the vendor-supplied drivers (for a USB3.0 motherboard or adapter card). Note that if you don't have a USB3.0 motherboard or adapter card, it will fallback to USB2. The last few Ubuntu releases will read and write NTFS partitions. -- Finlay McWalterTalk 20:15, 21 February 2011 (UTC)
The hard drive itself will almost certainly work with Ubuntu, or any other modern Linux distribution, even if it doesn't say it will. The file systems on the hard drive are another matter entirely. There are some file systems that are compatible with both, such as FAT16 and FAT32, but these won't take full advantage of either Windows or Linux. Windows these days uses NTFS, while Linux uses ext3 or ext4. I am not sure about their compatibility with different operating systems. When I buy a new hard drive to use on my Fedora Linux system, the first thing I do is reformat it as ext3 or ext4. JIP | Talk 20:41, 21 February 2011 (UTC)
Linux supports all major Windows-style file systems, including FAT16, FAT32, and NTFS. Support was provided in Kernel 2.6.0 using the NTFS-3G driver and FUSE. I regularly read and write to local and networked NTFS drives and partitions in the latest Ubuntu, without issue. Nimur (talk) 21:01, 21 February 2011 (UTC)

What font is this?[edit]

On my homepage http://www.stucktothefridge.co.uk/ I have no idea what the name of the font is which says "contemporary photography...."

Can anyone tell me or give me a few approximations so I can find something similar?

Lucas 83 21:24, 21 February 2011 (UTC) — Preceding unsigned comment added by Lukerees83 (talkcontribs)

Try running it through WhattheFont. PerfectProposal 00:55, 22 February 2011 (UTC)
Neuropol ¦ Reisio (talk) 13:48, 22 February 2011 (UTC)
There are a lot of very similar ones. This and this have similar lower case looks. They must all be aping some original font, but I don't know what it is. --Mr.98 (talk) 13:58, 22 February 2011 (UTC)

user agents[edit]

Why do almost all user agents have "Mozilla" in them? Even Internet Explorer — Preceding unsigned comment added by K4t84g (talkcontribs) 21:38, 21 February 2011 (UTC)

"Mozilla" was the user agent string used by Netscape Navigator. As Jamie Zawinski explains here (in "cloakers") IE pretended to be NN so it was served the same content. So now everyone does it. -- Finlay McWalterTalk 21:58, 21 February 2011 (UTC)
An accident of birth. 109.128.213.73 (talk) 23:42, 21 February 2011 (UTC)
A consequence of multiple poor choices. ¦ Reisio (talk) 13:51, 22 February 2011 (UTC)
As an inevitable result, this has led to people having to make their browsers pretend to be Internet Explorer-pretending-to-be-Netscape. User agent strings are modern sagas. In them, the history of the browser wars is forever retold, from client to server, down through the generations, forever. Paul (Stansifer) 18:23, 22 February 2011 (UTC)
Epic. --Ouro (blah blah) 07:16, 23 February 2011 (UTC)