Is learning ed worth it to boost my speed in VIM? - vim

I've learned the basic/intermediate levels of VIM (it's too vast to list). I often find that I slip back to my old ways and start using the mouse, holding down keys to get somewhere, and doing other stupid things that could be sped up.
Would it be worth spending time to learn ed to break the habits learned from years in a point and click interface? Does using ed cultivate the right type of thinking that will transfer to VIM?

You need a change in habits which is much deeper than simply dropping the mouse. You need to understand that if you really want to learn Vim you have to do it "the hard way": read and memorize text-objects (:help text-objects) operations and movements and try using arrows/hjkl as little as possible.
At first you will be a lot slower, but don't fall back to normal movement. If you need to select a paragraph, use vap, if you need to change the text inside a pair of double quotes use ci" and so on. When these things will come out of your fingers naturally, you'll realize how worth it was the time spent to get used to them.

I learned Vim and became proficient simply by using Vim itself--a lot. I think the key is practice, practice, practice.
If you want to train yourself to avoid the mouse, unplugging it or putting out of reach might help. Learning a whole different program might be overkill, and the knowledge may not translate directly.

Read this post by Bram Moolenaar on the subject of efficient text-editing.
One of the points is that it takes conscious effort to force yourself into the habit of using Vim efficiently.
So yeah, hide the mouse while you're in Vim. And when you catch yourself doing things "the wrong way", stop and do them again correctly. It won't be long before you've learned the proper habits. And has has been suggested: Text Objects. Learn them. Get in the habit of using these and you're 1/2way to being a Vim pro. Using them is addictive; it won't take long.
I think in addition to consciously avoiding the mouse, it also helps to consciously try to force yourself to keep your fingers on home row.

Related

Why are h,j,k,l recommended over using arrow keys for vim?

I am a vim user (not a beginner not advanced). I use the arrow keys.
I have repeatedly read that it is highly recommended to use the h,j,k,l keys for increased productivity.
I have tried to use them but I can not see how they help in being more productive.
Because if I am to use the h,j,k,l keys to move up/down/right/left I need to press the ESC first to exit the insert mode.
But that defeats the purpose doesn't it? Since the original idea is that you don't need to move your fingers away.
If I am to press ESC I might as well be using the arrow keys and save a keystroke.
Perhaps I am doing something wrong here?
Old terminal keyboards like the ADM-3A terminal didn't have arrow keys.
The keyboard layout looked like this and it already had the arrows for hjkl. (By the way, also note the relation between ~ and Home key)
I think it is mainly for historical reasons that vim still uses it (and many are used to it). Perhaps also because many sysadmins are nostalgic about stuff from the 70/80's, and because they can brag about how they can type faster (like typing is the cause of slow coding...).
The distinguishing feature of vi / Vim is that it's mode-based. That means:
you only stay in insert mode for short bursts of typing
in the other modes (mostly normal mode), you have all key [combinations] available for powerful editing commands (which are highly regular in Vim, and can be combined to great effect)
So, it's crucial that you can switch modes easily. For many users, that means remapping the Esc key to a more convenient location (replacing Caps Lock or Ctrl). Then, using H J K L for navigation (note those are only the basics, and it's often better to use more specific motions like w or f{char}) is quicker, because your fingers can stay on the home row (assuming you're a touch typist, which you should invest in if you spend considerable time with a computer). The cursor keys are located so far off that switching there takes too much time (using the mouse is even worse), and isn't good for your wrists, neither.
The problem with the arrows is not that they are too far: the problem is that they only allow you to move character-by-character and line-by-line. And guess what? That is exactly what hjkl do. The only benefit of hjkl over the arrows is that it saves that slight movement of the arm to and from the arrows. Whether you think that benefit is worth the trouble is your call. In my opinion, it isn't.
hjkl are only marginally better than the arrows while Vim's more advanced motions, bBeEwWfFtT,;/?^$ and so on, offer a huge advantage over the arrows and hjkl.
FWIW, I use the arrows for small movements, in normal and insert mode, and the advanced motions above for larger motions.
mouse-using sucker everyone laughs at: (move)↓↓↓↓↓↓↓↓↓↓→→→→→(move)
hjkl-obsessed hipster: jjjjjjjjjjlllll
efficient vimmer: /fo<CR>
h, j, k, and l are on the home row. If you move your hand to use the arrow keys, you have to readjust when you're done with the arrow keys. This is only a problem for touch typists (which everyone back in the day was).
If you like using the arrow keys, by all means, use them. There is one advantage I see over hjkl: arrow keys work in insert mode. Others prefer to move their fingers only minimally. That's a good argument if you are a touch typist and need to type lots of text. At least for me, my thinking is always slower than my editing, so typing speed and minimal finger movement are not so much an issue to me.
In the end, it's a pretty subjective matter. Use what works for you but try to look around and extend your horizon now and then.
h j k l are a stepping stone to more powerful features. Do you really think that left, right, up, down is as advanced as moving the cursor gets in the 21st Century (or 1976)?
Please note that arrow keys are not recorded while using "q" macros, and bring a lot of sheanigans when you are using some esoteric options because arrows interrupt them. The idea with vim is to end up using composable actions as often as possible and arrows are not.
Besides it doesn't make much of a difference anyway. I had the same strule as a kid switching arrows for WASD, once you get used to it it's just another way, closer to where your hand already is.
And it's not just vim, you would not believe how convenient it is to go the extra mile and learn the terminal shortcuts for movement, copy-paste, history, etc. My laptop's arrows broke last year and I couldn't find the time to solve the issue (Amazon reach the space, but not the island where I live). It was a blessing. Now I rarely use arrows anymore, because ctrl-p/ctrl-n/ctrl-b/ctrl-f/etc. it's just more ergonomic. I just lay my hands on top of the keyboard and don't move them anymore. Ironically now the fartest I move my hands from standard position is to press ESC, wich happens quite often in vim.
A few times I've heard "wait, your terminal/editor can do what!?" when doing fancy things with public. Probably their toolset can do it too, but they haven't go the extra mile of truly learning them. Trust me, it's worthwhile to do so. These tools have been designed this way for a reason.

Time to relearn touch typing? (Is this a Emacs / VIM thing?)

As a kid, I learned to type on a German keyboard1?. And even though my mom tried to make me use a "learn how to type with ten fingers" program I never did. My hands have their very own muscle memory about how to type. I found out that I use the index fingers most to reach many characters, while my hands are moving over the keyboard.
Now, here's the kicker (no flame intended!): I use and used emacs a lot and I've never really had an issue with the way I type, or at least it never felt too awkward. From time to time I like to explore VIM (and other editors) to see what has changed and which features are the new and hot features.
I came to the conclusion that, while my fingers /rest close/ to the home row, my hands move a lot and the default keyboard command layout in vim seems to prefere the fingers resting on the home row with little movement of the hands.
I don't consider myself to be a slow touch typist, but could a formal touch type education increase speed and accuracy? Furthermore is this a Emacs / VIM thing?
UPDATE: I headed over to http://typeracer.com/ :)
1: These days I type on US keyboards while switching between different layouts as needed.
Yes, you're a keyboard worker, learn to use a keyboard properly. No, it's not an Emacs / Vim thing.
If you are using emacs, makeing Caps_Lock another Ctrl key will ease strain on your little finger, when your hands are "locked" in the home row position.
for ubuntu
System->Preferences->Keyboard->
-->Layouts->Layout-Options-Ctrl key position->Make CapsLock an additional Ctrl
or for windows
Windows Registry Editor Version 5.00
[HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Keyboard Layout]
"Scancode Map"=hex:00,00,00,00,00,00,00,00,02,00,00,00,1d,00,3a,00,00,00,00,00
You don't need a formal education, but a lot of discipline, concentration, dedication and hard work will make you a touch typist in a few months.
Touch typing will greatly assist you in your life, if you plan to work with computers as your day job.
Force yourself to move your hands as little as possible and use all of your fingers all of your time.
Rest your left fingers on ASDF, your right fingers on HJKL and start typing. While typing, optimize your reach for every key pressed.
If you plan to be a computer professional, touch typing should be a rite of passage, although it isn't required. But just imagine what would it look like if a master pianist didn't know all keys on piano by heart?
Not really. Especially if you are going to alt-tab to google/read documentation a lot.
Touch typing as it is good only if you are not going to use mouse and F1-F12 which is never true in modern environment.
If you are going to use them, you'll eventaually switch to some form of mutant of touch-typing.
(also whoever thouGHT that typing H with riGHT hand is briGHT idea should be shot in THe face. Left hand do it more naturally in huge amount of cases)
I'd say don't worry about it. You're not a secretary or someone who is having to take down dictated speech. It's far more important for a programmer to spend more time thinking about what they're writing rather than how they write it. If speed of typing is your biggest concern over how productive you are I think you're probably productive enough.
Do you really care? If you do, use the editor that you are more comfortable with. If are you looking for alternative, use M-x viper or learn other emacs extensions that helps you type faster.

One handed coding -- tablet, special keyboard, one-handed typing?

I recently broke my finger and can now only type with my right hand. This has seriously impacted my typing speed. Since I write software for a living, this is a serious problem.
I have been doing some research, but haven't found a great solution yet. Here's what I've come up with:
Wacom tablet + hand writing recognition software. Is it possible to write code with hand writing recognition software?
one handed keyboards -- I have only found expensive (> $100) keyboards. These look like they have a steep learning curve.
one handed typing instructions: http://www.aboutonehandtyping.com/manualcompare.html. Does this really work?
What do the one handed coders out there use?
If you're a two-hand touch typist, the answer is a "mirrored" layout.
Mirroring lets you begin touch-typing with one hand almost immediately. Pretty crazy how easy it is. Based on the muscle memory you already have.
If you're typing with your right hand:
Type all right-hand keys normally.
Don't type left hand keys. Instead type the same motion (but mirrored) with your right hand.
So if you want to type:
"D" -> type "K" instead.
"W" -> type "O" instead.
"S" -> type "L" instead.
Same row of keyboard, same finger, same motion. Your muscle memory can already do this... kind of like how you're unable to pat your head and rub your belly at the same time. The wires in your brain are crossing somewhere.
Software to mirror the keyboard as described above:
Hold Spacebar to mirror:
Linux - MirrorBoard
Mac - Mirror-QWERTY
Windows - AutoHotkey version of Half-QWERTY Half-Keyboard
Predictive Text; Automatic Mirroring
Mac - One-Hand Keyboard
Windows - One-Hand Keyboard
Regarding one-handed keyboards, I've tried using a frogpad and found it ok for typing text, but unusable for coding. The symbols require several consecutive key presses and I found it impossible to use shortcuts reliably. It was too easy to hit the wrong key and get it stuck in the wrong mode.
Nobody has mentioned ENTI-key aka Coffee++ Layout yet? It is exactly designed for programming with one hand (left). And unlike qwerty, it is even optimized for speed and ergonomics. I used it some years ago for a short while and I don't know if it still works on newer systems. I think I used it for writing CSS: Typing the words with left, typing all those numbers on the numpad with right.
I can not recommend pen+handwriting. I usually use a tablet PC and handwriting code is terrible. I tried it on Windows 8 and Linux with Cellwriter, and both are not bad programs, but I still switch to onscreen keyboard whenever I can. But maybe the problem is my scratchy writing :)
I also can tell from experience that learning a new layout is not as complicated as it sounds. Especially if the layout is more logical than qwerty. I use Neo Layout since 10 years and getting the hang of it went smoothly, I was able to write a blog article after an evening of training.
"But what if you have to use qwerty on another PC?" This, also, is no problem, really. My simple trick is to never look at the keyboard when using Neo, but glimpse at it when qwerty-ing.
Good luck to anyone who wants to or has to use one hand for typing!
Now, the time to heal a broken finger will be shorter than it takes to adapt to one handed coding, not to mention the time it takes afterwards to get back to two-handed coding
Also, the time it takes to learn the methods is time you could've spend on coding (read: making a living).
Knowing this, we need a quick-fix, short term solution.
First of all, A good IDE, with code completion and similar functionality will help you a lot.
Secondly, use the shortcuts of the IDE, remember, there are Shift, Altand Ctrl keys on both sides of your keyboard.
(you might want to create a cheatsheet for those shortcuts)
In addition to helping you during your time with your injury, learning the shortcuts will also improve your coding speed when you're back up again.
Now, my comments on your proposals:
Don't, simply, Don't, it'll take even more time to fix writos (typos) beacause recognition will be flaky.
That learing curve will slow you down even more.
Won't even comment on that one...
Mirrorboard
A friend of mine broke his wrist snowboarding, and he had reasonable luck using speech recognition software (Nuance Dragon Naturally Speaking). It worked quite well for email and documentation, which would solve a part of your problem.
Another colleague, Nils Klarlund of AT&T, developed a version of emacs hooked into speech recognition. He even had a home-brewed set of foot pedals for doing shift, control, etc. He used this exclusively for years (due to bad carpal tunnel syndrome).
And maybe your feet can take up some of the burden. This is part of a parallel discussion going on in this question.
And off-topic, but extremely interesting, T.V. Raman, who's been blind since the age of 14, wrote a version of emacs that works with keyboard input and audio output. There's a chapter on it in Beautiful Code. I've seen him use it, and it's completely awesome. And of course emacs is a great interface for more than just text editing.
If you anticipate that your left hand will be out of commission for a long while, and if it's worthwhile for you to learn a new layout, then there exist one-handed Dvorak layouts.
There's some information at PC Guide: Single-Handed Dvorak Alphanumeric Layouts.
There also once was software for Qwerty Half Keyboards that used the space bar as an extra shift key that reversed the keyboard.
Good luck with your injury!
We have a developer in the office that lost mobility in his right hand and probably won't gain back full use of it. He has mainly learned to type well with his left hand and kind of fill in for his right hand. Although he lets his right hand kind of peck for things. He has gained enough speed back for it not to affect his day too greatly from what i can tell.
Only thing i can think of that might let you speed up some while typing with one hand and maybe being able to get a key or two with the other hand might be to use an IDE instead of text editor if you already don't, so you can use tab completion. Kind of a lame solution if you don't like IDEs or just don't have that option in your work environment but might help out a bit.
The same thing happened to me (I destroyed my left pinky). At the time, I didn't touch type, so my only use for my pinky was left-control, left-shift, and caps-lock.
This sounds as if it just happened to you. I promise you'll quickly learn to compensate. Remember, it's quality, not speed, that counts most.
Perhaps you should seize the opportunity and read to improve yourself as a programmer. Or spend some time debugging.

Inefficiency in Vim

I consider myself somewhat familiar with Vim,
hate the arrow keys (let alone the mouse),
regularly look up tips and plugins to get the most out of this tool,
use it daily to manage my cloud servers, etc.
However, I always find myself doing the same mistakes probably inherited from the GUI-world:
too often switching to visual mode to see what piece of code I'm about to manipulate,
undoing changes to retrieve lost statements because I forget to utilize registers (and pasting code on temporary lines just to grab it after other edits),
relying on Ctrl-C & Ctrl-V when working with operating system's clipboard,
keep pressing j button to browse through lengthy files to find certain functions.
Probably my Hungarian keyboard layout prevents me from being faster as most of the special characters (/, [, etc.) are only available as a key combination (with Shift or Alt Gr).
Given this specific situation, what pieces of advice could you give me? Have you faced similar bad habits when you were a Vim-novice? I'd like to see my productivity skyrocket (who wouldn't?). Thanks in advance.
I've found a simple, effective strategy. Choose one action, one task or one set of keys that you think is unnecessarily slow. Figure out a better way of doing this using the vim manual or googling or a plugin etc. Force yourself to use this every time. Rinse, and repeat. The path to efficiency is one-by-one elimination of the slow parts.
I'd also recommend just reading the vim manual from time to time - even if you don't remember everything, knowing something's out there is very helpful.
This probably applies well beyond vim, but
something that worked for me was finding a specific feature that I knew would
be more efficient and concentrate on using that for a week or two.
Just one feature at a time, and possibly using it excessively.
After a couple of weeks it becomes automatic and you can move on to the
next thing.
I learn programming tricks the same way. eg. I'll have a month of using lambda expressions for everything, then a month of mapping and filtering.
(not on production code though)
Probably my Hungarian keyboard layout prevents me from being faster as most of the special > characters (/, [, etc.) are only available as a key combination (with Shift or Alt Gr).
I'm sitting in front of german keyboards all day long and know this problem very well. Some keyboard layouts are simply not very suited for programming / using vim. I think its safe to assume that most programming languages and keyboard shortcuts were designed with the us-layout in mind.
My advice: reset your keyboard layout to us-english and practive touch-typing on that layout (typing without looking at the keys). It won't matter that the keyboard labels are wrong and you'll be much more comfortable using vim hotkeys.
The only problem that still remains for me is to produce language specific characters (german umlauts such as ä,ö,ü) wich i assume will also be a problem for hungarian. For that I use a combination of vim-digraphs, linux window manager digraph-key and windows layout-switching hotkeys.
just keep using it. The more you use it, the better you become at it. VIM isn't too bad. The main thing is you just have to remember that it isn't always in edit mode.

What is the best way to learn Touch Typing? [duplicate]

This question already has answers here:
Closed 13 years ago.
Duplicate
How do I improve my Typing Skills?.**
I tried the test on http://speedtest.10-fast-fingers.com/. I reach only:
You type 337 characters per minute You
have 58 correct words and you have 1
wrong words
How can I improve my typing speed? What free resources do you know of?
Should I learn the Dvorak Keyboard?
Practice is the best way to get faster. I've found TypeRacer to be a fun and easily accessible game. Using it I quickly got from around 55 words per minute to over 70.
I removed all of the key caps from my IBM Model-M. Since I can't see the letters, I was forced to learn their positions and type without looking at the keys other than to initially orient my hands. When you're not able to take shortcuts, you tend to learn very quickly.
Mario taught me.
I also took the test and reached 371 characters with one mistake. However, for programming, I would not see this as a bad result. I'm more worried about how to use tools like Intellisense and code templates better to speed up my coding. The jedi coding demo shows that you can get much higher gains that way than by doubling your typing speed.
No need to learn Dvorak according to XKCD (and more here).
I also remember reading in The Design of Everyday Things that QWERTY actually does quite a good job or spreading the commonly used letters across your fingers and whilst the Dvorak keyboard is a little better than QWERTY the benefits aren't significant enough to justify making the change. (If I can find my copy I'll try and put up an exact quote.)
As with all things: practice makes perfect. Making posts on StackOverflow is a start :)
Unless if you want to win typing contests, a Qwerty or Azerty keyboard will work just fine.
You don't need to learn Dvorak. I can type 600+ Chars/minute on a querty pad, no problem.
The key is: Repetition, repetition, repetition.
What you're doing while you learn typing is creating new 'highways' straight form your brain's spelling center through your spine to your fingers.
Hence, a good typist will spell a word in his mind, and his fingers 'automatically' type those characters because there's a 10 lane highway from his brain to his fingers. In your case, it's a modest 3 lane highway.
Practice, practice, practice.
Good training for if you already know how to type : www.play4traffic.com
There's also loads of typing tutor programs available online, but the key is repetition and persistance.
My native language is Dutch, so in english it's not as good. I tried the test you gave:
317 points, so you achieved position 194065 of 2927935 on the ranking list
You type 476 characters per minute
You have 80 correct words and you have 4 wrong words
Why?
Why do you want to type more quickly? I seldom find that my fingers or typing speed are the issue when it comes to software development. Sure I have a fair speed, but programming is about SO much more than typing speed. I've been using a QUERTY keyboard since about 1983 so I guess repetition helps.
But learning to hold back on typing and thinking about what it is you're about to do is far more valuable IMHO.
Having said that, I would expect any developer to be able to type reasonably quickly using most fingers, or at least more than their two index fingers ;)
This game taught me a few years back.
The Typing Of The Dead
I can now type fairly quickly without looking at the keyboard. You need to learn to use the correct hand position. Then you must have good discipline and only use the correct finger to type the correct letters. I even went so far as to delete correct chars typed with the wrong finger.
It takes time, and you will almost definitely go slower before you go faster, but it is worth it.

Resources