Let's stop telling programming newbies to learn Vim (or Emacs)
devblog.avdi.org
devblog.avdi.org
A: Ask a first-year CS student to quit out of Vim.
Keep your friends close, and your enemies closer :)
And yet, later on, when understood the editor's philosophy, I felt enlightened.
No one ever made me quit Editplus.
No one, until Sublime Text, that is.
So that's true, you have to follow your heart.
Editors that make me take may hands off the keyboard in order to click around in the gui to move around my files are productivity killers.
Don't state this as if it were fact. They're productivity killer for you. Because you have been using Vim for so long. A person who is balls deep familiar with Sublime Text 2 or Visual Studio will be just as fast due to experience.
I wouldn't state this as if it were fact either. The biggest gain for me is the ability to quickly and easily script my text editor to do tasks for me. Sublime Text 2 has a macro system, but it looks neither quick nor easy to write scripts for. Visual Studio looks like it no longer supports macros as of VS2012.
Your Vim setup is awesome, but for a newbie to vim like me, it'll take a long time before I'm more productive using it -- not only would I need to internalize the keybinds and text processing tools, but I would also then have to start adding custom scripts and stuff, in order to do other things. (run unit tests, evaluate a block of code in an interpreter, etc)
I wonder how many devs actually don't ever read man pages? Seriously, everyone should know how to surf man and do it well, start with man man.
I can open a file, search a random string and fix your damn configuration file over ssh using vi/vim.
I will however, keep using Sublime Text 2 over Vim almost every single time, thank you very much. Vim usability sucks.
Also, try to play some Starcraft competitively before dismissing the mouse as productivity killer. In the right hands those bastards are FAST.
Selecting and moving a string from a random part of a line to the middle of another line is faster with a mouse than with keystrokes. Not by much, but it is.
... but touchpads are relatively much less precise than mice, especially when used with your thumbs. For many activities, this matters (e.g. precision is required to select text in many cases; it can be maddening to have to continually re-select the same text because you keep missing the first character...).
I've noticed many people actually switching to "touchpad mode" for precise movements, where they move their whole hand down and use their index finger on the pad. This seems to increase the accuracy somewhat, but of course incurs the same switching overhead as a mouse...
A couple thoughts on that:
1. Allowing you to take your hands off the keyboard in order to click around in a GUI is not necessarily the same thing as making you do it. Even in Visual Studio experienced users' hands tend to stay put. For example, to open up a file to see some other element's code, there's no sense in bothering with the mouse. Not when with a single keypress you can jump not only to the correct file, but to the correct position within that file.
2. On the other hand, needing to consult the manual in order to find out how to do something is often more time-consuming than mousing through a menu. In a well-developed GUI, mousing through a menu is also the quickest way to figure out a new keyboard command. Much quicker than Googling or digging through manpages.
3. Even if you haven't bothered to learn the keyboard commands for your graphical editor, if you're switching what file you're working in frequently enough that the fraction of the second it takes to click on a tab is adding up to anything remotely significant, then you've probably misplaced the blame for your productivity issues. If you're switching files that much, the amount of time you're wasting on mental context-switching is probably immense.
Naturally all this assumes that one is using a well-designed graphical text editor, and sadly the vast bulk of graphical text editors simply aren't anywhere near as refined as emacs or vim. Especially not if you need one that's cross-platform. But let's be careful not to make radios out of coconuts here: The reason emacs and vim are so effective is because they are venerable, not because they are textual.
I think there is another skill, somewhat related to programming, that we need to teach before programming: text slicing and dicing.
The entire point of a programmable powerful editor is to apply text transforms more quickly than you could with click and type. If that's important, then we should teach it first. I personally believe it is important because of the huge productivity multiplier it gives programmers.
:set wm=4 (wrap margin)
Or :help gq to see plorkyeran's suggestion.
nnoremap <leader>W :set colorcolumn=0<cr>:set syntax=markdown<cr>:nnoremap j gj<cr>:nnoremap k gk<cr>
In Eclipse, control-shift-a will toggle it, and in Komodo you can just use alt-shift to select in a column. (I like Eclipse's mode toggle better, frankly.) It exists in several other editors, of course -- I think Sublime Text 2's demo reel includes it.
The difficulty he is describing here applies to vim/vi only (modal text editing). With emacs the default setup has menus, typing inserts text into the document. You can do file->save. It is newbie friendly because you can learn bits and pieces of the powerful stuff as you go
Given that there's actually a rather small number of "standard GUI" keybindings, it actually seems much more tractable to simply ask people to relearn those. It simply isn't a huge burden compared to the alternative...
The sort of people who would be completely loathe to relearn the few "standard GUI" bindings will probably use the mouse/menus instead anyway (and I've observed many newbies happily using Emacs without ever touching the keyboard except when entering text!).
My preferred editor is emacs, but there is no way I'd try to have people use emacs in their first programming class. We are using Ubuntu computers, and I am currently having students work in Geany.
Are there any other suggestions for editors on ubuntu machines, that are friendly to new programmers?
It would be unpleasant to edit in nano/pico full time (no syntax highlighting or indentation help, etc.), but if you have to do something through ssh and emacs or vim are still too much, they get the job done. What makes them new-user-friendly is that they keep a "menu" of basic commands visible at the bottom of the screen. So you can always see how to save, quit, etc.
For GUI editors, Gedit and Kate were pretty popular for (K)ubuntu and other Debian derivatives.
Imagine you want to quickly change a directory path in httpd.conf, instead of downloading the file, editing and then uploading it via FTP - just nano that sumbitch and you're done.
I learn how to use it in about 30 minutes. That's really all it takes to get the basics down.
C-x C-f /ssh:user@host:/path/to/httpd.conf
... and I have it open in my local emacs, with my own settings, with colour and indenting, and no lag when I'm editing. (this is called tramp mode)
And if I then typed M-x eshell, I'd have a shell at the directory where I opened that file, and the nano users would start shouting 'burn the witch!'.
Other editors also support remote editing over ssh - no need to download/upload, the editor takes care of that for you. Working this way, I don't even have to trust that the remote server has nano or emacs or whatever - which it often doesn't.
Some power behind it, not unsimilar to Vim/Emacs. Some beauty behind it, not unsimilar to other commercial text editors / IDEs.
The truth is the editor you use doesn't matter. People who know Vim swear up and down on it, but that's because they are good with it, they have been using it for over 5 years - of course they're proficient with the editor.
Other people are fast with editors like Sublime Text 2.
Others with an IDE like Visual Studio or RADRails.
Tools don't matter, your workflow does. Personally, I'd teach those kids how to use Sublime Text 2.
Who the hell uses default Emacs key bindings anyway? ;-)
It has a built in console, which is great to keep focused on single screen. Instead of resizing and shuffling windows, just keep it all in one display. Press F5 to run your code. Fire up a console and try something out (with autocompletion in the console too).
It also has built in documentation, an object explorer, and some other cool features that are escaping me. It hasn't always treated me nicely (sometimes it forgets to reload my code, or it goes out of style (literally, it loses styles sometimes)), but overall it's a good spearhead for getting up to speed quickly with Python.
Spyder - http://code.google.com/p/spyderlib/
Why spend so long worrying about your IDE of choice when they are all effectively glorified text editors?
edit: I'm glad that my comment provoked such a fantastic discussion
Will it make me type faster and think faster? I spent 6 months working in a doctors office were I had to type every word spoken for 7 hours a day, the block here is not my efficiency, it is in fact my intelligence.
No, but syntax highlighting greatly enhances code readability and your brains ability to recognize what types of objects or properties or functions are being represented in code. Associating the color blue with a variable declaration, for example, is just there as a visual cue or shortcut for your brain.
I understand your point that it can be done perfectly fine with notepad, but let's not pretend that these visual cues don't give your brain a jump-start.
But I still pose the question, why is it worth the time to learn what is considered a complicated IDE (if it needs to be taught)? Would the time not be spent better, say, being genuinely productive, rather than merely preparing for future productivity?
We live in the here and now, my boss wants to hear that my project will be done on time, not that it will be a week late because I need to learn the more fickle aspects of an IDE he didn't sanction before I can finish it.
Little things like jumping to a function with pressing a button, or finding all things that are referencing a function\class\etc are extremely useful, but certainly not necessary. Then things like intellisense are a godsend.
That being said, a lot of my time is spent out of visual studio, but with Sublime Text which add's a lot of things that simply make me have to type less, and focus more on the actual task at hand.
why is it worth the time to learn what is considered a complicated IDE (if it needs to be taught)? Would the time not be spent better, say, being genuinely productive
Why delegate work when that takes time you could spend doing the work yourself? Because you can't do everything. At some point delegating starts to pay a return on the effort.
The goal is for You + Computer to create a system which is greater than the sum of its parts. For you to use the computer as an external brain.
If it's just you and notepad-as-typewriter, you're doing all the work.
You shouldn't spend a week learning about an IDE feature in the middle of your project, but you should eventually spend ten minutes to learn to write a macro instead of making the same change seventy times, and maybe you should spend an hour and a half wiring your editor up to your favorite static analyzers and compiler so that you can test and debug your code quickly over the next month.
Vim is very well suited to programming because we spend a significantly longer time thinking about, navigating and modifying code than actually writing it.
That's how most people do programming and Vim is ace for all of that thanks to:
* text-objects and motions to fly through your code and edit with laser-like precision in as few keystrokes as possible
* counts to perform repetitive actions in a flash
* ranges for when you want to act on a specific part of the file
* incsearch
* :global
* macros
* :s/foo/bar
* etc.
When it comes to actually write new code, Vim doesn't help much. Well… if you don't consider:
* filename completion <C-x><C-f>
* keyword completion <C-n>
* line completion <C-x><C-l>
* <C-r>= to insert the result of an expression
* <C-y> to input the char above the cursor
* etc.
But then again, we are talking about programming, here, and nobody ever pretended that Vim was the answer to every problem. Or even your problem, for that matter.
In a situation like yours, I'd probably use something like Dragon or simply use stenography like my secretary mother did 30 years ago. I'm very much in love of Vim, actually, but I wouldn't recommend it to anybody that is not a somewhat experienced coder. And even then, there's an entire population of programmers who spend their days generating code, fighting against OOP hell and refactoring refactorings. Those people would probably not derive any benefit from using Vim. Just like you. And nobody is trying to sell them Vim. Just like you.
Use the right tool for the job.
Why spend so long worrying about your Hammer of choice when they are all effectively glorified Rocks?
When I get home it's anything from C++ to Java, but occasionally in my spare time I throw together the occasional Python script (and once, Ruby, when I was working with a program called GameMaker which accepted plugins only as DLLs or imbedded ruby scripts)
You can certainly code in Notepad, and you can write code with "cat > filename" too. Most of us that have had even the slightest exposure to more powerful editors dismiss Notepad as "Not the Right Tool for Programming", in much the same way that a chef will dismiss a butter knife (or a spoon) as not a proper tool for slicing vegetables. Consider that there may be some merit in such an assessment, and that there may be ways in which other editors may serve you better.
If you _seriously_ use Notepad regularly as a programming editor, I urge you to try Notepad++ or Komodo as an alternative for at least a WEEK, and see what you like better about Notepad. This will help you overcome the initial unfamiliarity enough to see the things that they offer which Notepad does not.
In the other editors: - You can open more than one file easily. - They will re-open what you last had open, if you like (I do). - Komodo will recognize nearly every format you might be coding in, and color-code it in a way which helps reduce errors, because you can immediately see when the color coding is different from what you expected. - Some editors will flag syntax errors as you type.
Give it a shot. Try another editor. Nearly any other editor. I personally enjoy using Komodo at home and at work. Sublime Text 2 is beautiful, though its keybinds do not agree with my muscle memory. Notepad++ is free and awesome.
Notepad++ with its syntax highlighting is awesome.