New to python, do I need an IDE or is vim still good enough?

Cameron Simpson cs at zip.com.au
Tue Jan 1 05:12:57 EST 2013


On 01Jan2013 03:46, Steven D'Aprano <steve+comp.lang.python at pearwood.info> wrote:
| On Sat, 29 Dec 2012 14:00:23 -0500, Mitya Sirenef wrote:
| > [...] For instance, if I need to change
| > a block inside parens, I type ci) (stands for change inside parens),
| > while with a regular editor I'd have to do it manually and by the time
| > I'm done, I'd forget the bigger picture of what I'm doing with the code.
| 
| See, by the time I remembered what obscure (to me) command to type, or 
| searched the help files and the Internet, I'd have forgotten what the 
| hell it was I was trying to do.

Well, the idea is that your fingers become familiar with the core
commands. An issue of practice. The more complex vi commands are usually
composed from smaller pieces, so the learning curve isn't as steep as it
initially appears. Eg "%" jumps to that matching bracket. And
_therefore_, "c%" changes all text from here to the matching bracket.
There's a whole host of these.

| With a GUI app, I can run the mouse over the menus and see a high-level 
| overview of everything the app can do in a matter of a second or two. 

Well, there is GVim, a GNome X11 interface to vim. I imagine it would
offer that kind of mode.

| (Perhaps three or five seconds if the app over-uses hierarchical menus.) 
| But with a text interface, commands are much less discoverable. I can 
| also use *spacial* memory to zero in on commands much more easily than 
| verbal memory -- I have no idea whether the command I want is called 
| "Spam" or "Ham" or "Tinned Bully Beef", but I know it's in the top 
| quarter of the "Lunch" menu, and I will recognise it when I see it.

I must admit I find Apple's "help" search box neat this way - you can
type a keyword is it will actually find the menu item for you. Not that
I use this for vi, of course...

| > Another example: >ap stands for "indent a paragraph (separated by blank
| > lines)". And there are many dozens if not hundreds such commands that
| > let you stay focused on the logic of your code.
| 
| Ah yes, the famous "a for indent" mnemonic. *wink*

No, ">" is indent: it means shift-right. For Python you'd set the
shiftwidth to 4 (well, I use 2). But again, that's a grammar. Like the
"change" example above it is ">" followed by a cursor motion. So I'm
quite fond of ">}". "}" means jump to next blank line (or end of
paragraph for a prose paradigm). So ">}" means shift right from here to the
next blank line.

When your fingers know the cursor motion commands, folding any of them
into a compound command like "c" or ">" or "<" (guess what that one is)
requires almost no though. It's almost like speaking - you don't think
about grammar in your native language.

| It seems to me, that by the time I would have searched for the right 
| command to use, decided which of the (multiple) matching commands is the 
| right one, then used the command, it would have been quicker and less 
| distracting to have just done the editing by hand. But now I'm just 
| repeating myself.

To repeat yourself in "vi" you just type ".". See? So much faster than
your paragraph above:-)

Cheers,
-- 
Cameron Simpson <cs at zip.com.au>

As your attorney, it is my duty to inform you that it is not important that
you understand what I'm doing or why you're paying me so much money. What's
important is that you continue to do so.
        - Hunter S. Thompson's Samoan Attorney



More information about the Python-list mailing list