[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1205
  • Last Modified:

vi editor: h, j, k, l keys VS cursor arrow keys?

I'm starting out in UNIX and have chosen vi to be my editor for now;

Taking a vimtutor - it suggests using "h, j, k, l keys" to move around...

I find the cursor arrow keys much more comfortable...
But I want it to be the right way & for the long run... so what do you - the experts suggest and why?

Questions:
Which key combination is best to use and why?
And also any other great way to learn vi besides practice?

Thank you...
0
InGearX
Asked:
InGearX
  • 3
  • 3
  • 2
  • +9
5 Solutions
 
gripeCommented:
I suggest learning the 'vi(m)' way. Despite being somewhat odd at first, these keys are very useful and because they're all located on the home row you can move around very quickly. 'vi(m)' is a very powerful editor once you get past all of it's quirks. It requires a significant paradigm shift from the usual stateless editors but it's worth the effort.

The best way to learn vi(m) is to use it. You'll find, especially for tasks like programming or simple text editing that it's very efficient once you learn the basics. You will be surprised at how quickly you become proficient when you force yourself to use it. When I was learning years ago, I found that it helped to have a cheat sheet to refer to on my desk. Here's a link to a good one:

http://www.fprintf.net/vimCheatSheet.html

There are a lot of tricks and shortcuts you can learn just by reading through the sheet a few times, so I suggest skimming through it a couple times before starting. Nowadays I install gvim on all of my windows machines and don't edit any plain text files in anything else, you'll likely get bitten by the vim bug too if you let it.
0
 
avizitCommented:
>>>I find the cursor arrow keys much more comfortable...
But I want it to be the right way & for the long run... so what do you - the experts suggest and why?


some ppl findthat you can use the hjkl keys without moving your hand to the numpad .and hence faster .  Its a matter of personal taste.
0
 
avizitCommented:
>> And also any other great way to learn vi besides practice?

heh that sounded like  learning to swim without  going to the water ;) . Anyway don't practise for practising sake . try to edit files in vi (m) when you need too . as in edit your c-programs etc in vi(m) instead of whatever you use currently and pretty soon you should be comfortable.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TintinCommented:
I would *highly* encourage you to learn to navigate without the cursor keys.

You'll find it *much* faster and easier once you get used to it.  

It also means that you aren't reliant on your TERM setting being correct, or if you are on a terminal/device that doesn't have cursor keys, or if you are connecting over a really slow/unreliable network.
0
 
avizitCommented:
one more thing i forgot to mention  the hjkl keys are on the home row ( in the qwerty keyboard atleast ) ;)
0
 
jgiordanoCommented:
there are some remote connection utilities that don't like the cursor keys and won't navigate with them.
0
 
InGearXAuthor Commented:
Thank you all...

I find it hard to imagine prefering (g)vim over UltraEdit and all the visual advantages... we humans recive 90+% of our info via vision and thus I find the more info/tools you have the more efficient you are thus (g)vim VS i.e. UltraEdit...

What do you think?
0
 
wesly_chenCommented:
Hi,

   How about emacs, another popular text editor in Unix/Linux world?

   Different people have different taste. Find you own favorite that suits you.

> you aren't reliant on your TERM setting being correct, or if you are on a terminal/device that doesn't have cursor keys,
> or if you are connecting over a really slow/unreliable network.
Tintin is right since vi is the first full page text editor in Unix world and "hjkl" is its original design. All the latest version need
to backward compatible to it and you will find it helpful when you encounter those situation.

Regards,

Wesly
0
 
gripeCommented:
InGearX:

> I find it hard to imagine prefering (g)vim over UltraEdit and all the visual advantages... we humans recive 90+% of our info
> via vision and thus I find the more info/tools you have the more efficient you are thus (g)vim VS i.e. UltraEdit...

When you're editing a text file, the visual information you should be concentrating on is the content of the text file. Anything beyond this is superfluous and hinders rather than helps. If you can keep your mind on typing and editing rather than switching to cursor keys, mouse, reading drop-down menus and answering context windows, you can be more efficient. I doubt there's anything that can be done in UltraEdit that can't be done in vim in less time. (Maybe this is a challenge? :)


0
 
jgiordanoCommented:
honestly once you become proficient @ vi it becomes second nature. I actually like it better then using a graphical windows text editor. When I go back to my windows box, i often find myself issuing a !wq in notepad.

Everything is @ your fingertips with vi...
0
 
gheistCommented:
hjkl works on terminals withour COOL arrow keys ...
0
 
ahoffmannCommented:
stolen from man vi:
   vi - screen-oriented  (visual)  display  editor

so, what is not "visual" with vi?

I'd complete the votes for hjkl in first step, it works always, anywhere, even on DOS' 250kb vi and any dumb terminal used somewhere remote and .. etc. etc. etc.

> I doubt there's anything that can be done in UltraEdit that can't be done in vim in less time.
to complete the challange here too: if we keep anything except editing beside (like IDEs), I've never seen something faster than vi
Also, moving towards IDEs: have a look what (c)tags can do with vi (roughly 30 years old:-)

BTW, how many hands do you need to efectivily use something like Ultraedit (with all its buttons and menues)?
0
 
InGearXAuthor Commented:
Thank you all very much...

I think I'll just use the arrow keys:

1) I use them every where else... thus it's very natural for me...

2) The
Insert/Home/Page Up
Delete/End/Page Down
Are right above the arrow keys which are very efficient...

3) h, j, k, l keys were made for 'UNIX keyboards'  as it was explained to me; Therefore part of "h, j, k, l keys" purpose is outdated... and you need to move away from home row when pressing ESC anyway...

Regarding UltraEdit ... I'll make a little challenge soon... such editors have some very advanced features, most accessible by keyboard short-cuts... i.e. can vi replace string a for b in all *.html files and provide a pleasing output of what and where was replaced where i.e. opening any edited file simply involves right-clicking (or option key - left of right control) on the path and selecting open the location, and it's opened it a tab on top! The visual advantages just put them both into two different dimensions - not even able to be compared - because GUI gives so many advantages...

(do not forget I'm not taking about just UltraEdit but all those advanced GUI editors and don't forget 100% of options can be archived without touching the mouse too)

What do you think?
0
 
ahoffmannCommented:
> .. can vi replace string a for b in all *.html files
AFAIK vi not, but vim
But this is not a usual job for the editor but for "something arround" the editor (see my IDE-comment)

> .. and provide a pleasing output of what and where was replaced
vi no, not shure for vim, but: I never needet that, 'cause a single u-hit undoes anything ;-)

> .. simply involves right-clicking (or option key - left of right control) on the path and selecting open the location, and it's opened it a tab on top!
> ..  because GUI gives so many advantages..

I don't see an advantage here, see vi's tags functionality: there this is a single key-hit: Ctrl-T or Ctrl-[  ready. Could it be simpler? And I don't need to search a mouse or whatever under all my coffee cups ...

Let's stop pros&cons of vi against GUI, it ends in troll war, usually. hjkl have been answred.
0
 
gheistCommented:
Esc:g/old/s/new

....
0
 
CaseybeaCommented:
You asked two questions here----  one about the keys, but the other about "how to practice (without using vi)".

years ago, I spent a lot of time playing a pretty cool dungeon game- "rogue".   Later, it evolved into "nethack", and it's still alive and kicking today.

Both rogue and nethack, by default, use the "vi" navigation keys for you to move your little figure around.       It helps you get used to the hjkl arrangement, and you can have some cool fun besides.

www.nethack.org

enjoy :-)

0
 
urbanweaselCommented:
I recommend the keys hjkl if you use the ksh repeat previous command the arror keys dont work. you have to use esc k to repeat previous command the hjkl to move the cursor  
Jeff  
0
 
jmcgOwnerCommented:
A possibly interesting historical tidbit:

The hjkl convention arose because that's where the arrow legends were on the keyboard of the Lear-Siegler ADM-3A terminal that had come into fairly common use at about the time Bill Joy was writing the first versions of the 'vi' editor.

http://www.tentacle.franken.de/adm3a/

0
 
CaseybeaCommented:
Nice reference!    I always thought it had something to do with the old VT100 terminal http://vt100.net/docs/vt100-ug/chapter1.html#S1.1

But, although the VT100's arrow keys ARE in a straight horizontal row, the order is NOT the same.     I'll have to bookmark that ADM terminal reference.

0
 
dtkernsCommented:
AAHHHHHH!!! i lost lost my 50 lines of text when i hit esc in this window. who broke this GUI?!?!

2nd time:

I've been using vi for 20 years, and I rarely navigate with hjkl

I move around with ctrl-F, ctrl-B (page at a time) or / ? n N for searching forward/backward

I also use $ 0 w W b B { } [[ ]] alot too

I've tried several times to move to a "new" editor, but I can't live without my ! command that lets me filter any/all my document through the unix command of my choice (97% an inline awk command, 2.999% sort)
0
 
gheistCommented:
I use 99<enter> to get to some line
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
  • 2
  • +9
Tackle projects and never again get stuck behind a technical roadblock.
Join Now