Efficient Vim editing? Hitting a wall.

17 views
Skip to first unread message

703designs

unread,
May 2, 2008, 10:20:05 PM5/2/08
to vim_use
I know how to use the keyboard for all sorts of basic navigation
(paragraph, sentence, word, etc. etc.), yanking text, and quite a few
other commands. I've figured out the rudiments of editing my .vimrc,
and think that I'm actually relatively comfortable working exclusively
in Vim. Here's my problem: It's being a pain in the ___ to work with.
Constantly having to press "Esc" and "i" gets old quickly when you
just want to do quick edits, and I have yet to find an alternative.

"I" and "A", "o" and "O", the "r" command, etc. all help to reduce the
number of keystrokes. I suppose I could map Ctrl+A to do the tedious
"ggVG" to select all text...even so, while I've built up a good muscle
memory for many commands, I'm still editing slowly...I feel like I've
given Vim a very fair shake; what am I doing wrong? Any tips to help
me get further up to speed?

703designs

unread,
May 2, 2008, 10:22:36 PM5/2/08
to vim_use
Also, the "." command has been limited in capability because it
doesn't allow me to mix complex motion and insert commands.

Mark Wilden

unread,
May 2, 2008, 10:26:56 PM5/2/08
to vim...@googlegroups.com
On May 2, 2008, at 7:22 PM, 703designs wrote:

> Also, the "." command has been limited in capability because it
> doesn't allow me to mix complex motion and insert commands.

Macros help there, but they do require forethought, unlike .

///ark

Mark Wilden

unread,
May 2, 2008, 10:32:41 PM5/2/08
to vim...@googlegroups.com
On May 2, 2008, at 7:20 PM, 703designs wrote:
> It's being a pain in the ___ to work with.
> Constantly having to press "Esc" and "i" gets old quickly when you
> just want to do quick edits, and I have yet to find an alternative.

It's a tradeoff, in my opinion. In exchange for bracketing insertions
with i and Esc, you get to navigate without moving your hands from the
home row (and without most of the multi-key chording necessary with
emacs).

How long have you been using Vim? I've been using it for almost 25
years, off and on, beginning with a version I wrote myself. I still
get irritated at it (mainly when I forget to leave insert mode) but
I'm still learning lots of cool things to do with it. Because I've
gone back and forth to other editors, I've confirmed to myself that
Vim really is the most pleasurable for me to use. Maybe you should try
using a "standard" editor (or even emacs) for a while to see if Vim is
really for you?

///ark

703designs

unread,
May 2, 2008, 10:54:13 PM5/2/08
to vim_use
I've used TextMate for about eight months, and I've used Vim on and
off over the past couple years. I've been using Vim nearly exclusively
over the past six weeks, studying the commands closely when editing,
but even as I've gotten comfortable with the commands that are
supposed to be Vim's most powerful, I've seen no productivity gain
worth mentioning. The reputation of Vim is that, once you get over the
"learning curve", things are great, and I think that I've at least
gotten over the first curve. I think that Emacs may end up catering
more to my style, but I haven't really done much of anything with it.

Here's what I think is the big problem: I can't use all of Vim's neat
navigation commands when in insert mode. When editing my code, I often
do many small edits within the same line. "esc + w + i" gets old fast.

Erik Falor

unread,
May 2, 2008, 11:04:11 PM5/2/08
to vim...@googlegroups.com
On 5/2/08, 703designs <thomas...@gmail.com> wrote:

I've used TextMate for about eight months, and I've used Vim on and
off over the past couple years. I've been using Vim nearly exclusively
over the past six weeks, studying the commands closely when editing,
but even as I've gotten comfortable with the commands that are
supposed to be Vim's most powerful, I've seen no productivity gain
worth mentioning. The reputation of Vim is that, once you get over the
"learning curve", things are great, and I think that I've at least
gotten over the first curve. I think that Emacs may end up catering
more to my style, but I haven't really done much of anything with it.

Here's what I think is the big problem: I can't use all of Vim's neat
navigation commands when in insert mode. When editing my code, I often
do many small edits within the same line. "esc + w + i" gets old fast.


On May 2, 10:32 pm, Mark Wilden <m...@mwilden.com> wrote:
> On May 2, 2008, at 7:20 PM, 703designs wrote:
>
> > It's being a pain in the ___ to work with.
> > Constantly having to press "Esc" and "i" gets old quickly when you
> > just want to do quick edits, and I have yet to find an alternative.
>

Here are a couple of tips that will save you some keystrokes:

Instead of leaving home-row to type Esc, try Ctrl-[

In insert mode, hit Ctrl-o to enter command mode for a single command; after the command, you go back to insert mode.  This will let you do the equivalent of "esc + w + i" in fewer strokes, and w/o moving your left hand off home row.


> It's a tradeoff, in my opinion. In exchange for bracketing insertions
> with i and Esc, you get to navigate without moving your hands from the
> home row (and without most of the multi-key chording necessary with
> emacs).
>
> How long have you been using Vim? I've been using it for almost 25
> years, off and on, beginning with a version I wrote myself. I still
> get irritated at it (mainly when I forget to leave insert mode) but
> I'm still learning lots of cool things to do with it. Because I've
> gone back and forth to other editors, I've confirmed to myself that
> Vim really is the most pleasurable for me to use. Maybe you should try
> using a "standard" editor (or even emacs) for a while to see if Vim is
> really for you?
>
> ///ark
Erik Falor
Registered Linux User #445632 http://counter.li.org

Tony Mechelynck

unread,
May 2, 2008, 11:20:08 PM5/2/08
to vim...@googlegroups.com

The key word is: customizability and variability. Everyone is different,
so I bet that my vimrc and my custom plugins, keymaps and colorscheme
would probably not suit you very well.

Find out which kinds of tasks you use repetitively; these are the ones
to make shorter and faster, but depending on what they are for, there
are several ways to make them easier:

- mappings (but which kind? see |map-overview|)
- abbreviations (they are not the same as mappings but the difference is
subtle)
- functions
- user-commands (sometimes it is useful to define a user-command which
does nothing else than invoke a user-defined function).

and also, to make Vim behave differently by default:
- option settings
- autocommands
- scripts of the various kinds distributed with Vim, but which should be
housed in other 'runtimepath' directory trees -- $VIMRUNTIME is for the
distribution only, and anything in that tree can be silently replaced by
any upgrade, and probably will -- next week, or two years from now.

Summary: no task too big, no task too small; just identify them, and
find the right tools for them.

One very important thing: study the help. Not from beginning to end, but
the way you would pass the time with a fascinating encyclopedia: start
with something which you find interesting, or with anything at random,
and follow links to other articles, and from there to still others. [You
wouldn't read a dictionary from A (letter) to A (abbreviation) to a
(article) to a- (prefix) to -a (suffix) to whatever comes next in
straight alphabetic sequence until you get to zymogen to zymotic to
zymurgy to Zyrian, would you?]

To that goal I have found the following useful:

:help
:help {subject}
try it literally: brace, s, u, etc.; and see
:help 'wildmenu'
:help 'wildmode'
:help c_wildchar
:help c_CTRL-D
the latter two (and also the two above them)
for helptag completion, after typing :help
plus part of the name of a help subject.
Also for all other kinds of completion of course

Ctrl-I (next jump)
Ctrl-O (previous jump)
Ctrl-T (previous tag)
these three to navigate help history

and, last but not least: the |:helpgrep| command.


Best regards,
Tony.
--
If an elephant is left tied to a parking meter, the parking fee has to
be paid
just as it would for a vehicle.
[real standing law in Florida, United States of America]

Jeffrey 'jf' Lim

unread,
May 2, 2008, 11:38:03 PM5/2/08
to vim...@googlegroups.com
On Sat, May 3, 2008 at 10:54 AM, 703designs <thomas...@gmail.com> wrote:

Here's what I think is the big problem: I can't use all of Vim's neat
navigation commands when in insert mode. When editing my code, I often
do many small edits within the same line. "esc + w + i" gets old fast.

i personally use 'imap jj <ESC>' when i'm lazy and want  to avoid the "2-finger thing" (C-]), but really, C-o (WOW!! I just learnt that!!!) is really wonderful too... it's "2-finger" again, but it saves on having to do that 'i' after the navigation command...

-jf

--
In the meantime, here is your PSA:
"It's so hard to write a graphics driver that open-sourcing it would not help."
-- Andrew Fear, Software Product Manager, NVIDIA Corporation
http://kerneltrap.org/node/7228

Tony Mechelynck

unread,
May 2, 2008, 11:39:18 PM5/2/08
to vim...@googlegroups.com
On 03/05/08 04:54, 703designs wrote:
> I've used TextMate for about eight months, and I've used Vim on and
> off over the past couple years. I've been using Vim nearly exclusively
> over the past six weeks, studying the commands closely when editing,
> but even as I've gotten comfortable with the commands that are
> supposed to be Vim's most powerful, I've seen no productivity gain
> worth mentioning. The reputation of Vim is that, once you get over the
> "learning curve", things are great, and I think that I've at least
> gotten over the first curve. I think that Emacs may end up catering
> more to my style, but I haven't really done much of anything with it.
>
> Here's what I think is the big problem: I can't use all of Vim's neat
> navigation commands when in insert mode. When editing my code, I often
> do many small edits within the same line. "esc + w + i" gets old fast.

I would say that, unlike with e.g. Notepad, Vim's learning curve is slow
but long -- you don't learn the same percentage of it the first day, but
you keep learning for years, until you reach heights of which a Notepad
user would never dream. I would say Notepad is like the step between the
road and the sidewalk: you scale it in one step but it doesn't bring you
very high -- while Vim is like a long winding road: there may be quite a
travel from the seaboard to the mountaintop, but oh boy, what a
landscape! -- and you can enjoy it long before you reach the end (if
ever you do).

Best regards,
Tony.
--
"To err is human, to forgive, beyond the scope of the Operating System"

Tony Mechelynck

unread,
May 2, 2008, 11:54:14 PM5/2/08
to vim...@googlegroups.com
On 03/05/08 04:54, 703designs wrote:
[...]

> Here's what I think is the big problem: I can't use all of Vim's neat
> navigation commands when in insert mode. When editing my code, I often
> do many small edits within the same line. "esc + w + i" gets old fast.
[...]

See ":help i_CTRL-O": hitting Ctrl-O in Insert mode will let you execute
one Normal-mode command (which can be as short as k or as complex as a
full ex-command) and thereafter you'll be back in Insert mode. Also, Vim
can use the arrow keys: compare what the following do in Insert mode,
they do "almost" the same.

<Esc> w i
<Ctrl-O> w
<Ctrl-Right>

Another example:

<Esc> k a
<Ctrl-O> k
<Up>


Best regards,
Tony.
--
"See - the thing is - I'm an absolutist. I mean, kind of ... in a way ..."

John Beckett

unread,
May 3, 2008, 2:24:20 AM5/3/08
to vim...@googlegroups.com
703designs wrote:
> Constantly having to press "Esc" and "i" gets old quickly
> when you just want to do quick edits, and I have yet to find
> an alternative.

True Vim usage only occurs when you frequently use f (with ; and ,) to move the
cursor within the current line, and c to change text (stuff like 'ct,' for 'change
to comma'). Then, you get real benefits from the . repeat. This applies mainly to
editing programs, although I suppose it might sometimes help with poetry.

It's useful to force yourself to study the following. You don't have to worry about
the more esoteric things like ! for filter, but you need to be really familiar with
the keys on the three main rows:

http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html

John

Hugo Ahlenius

unread,
May 3, 2008, 9:49:57 AM5/3/08
to vim...@googlegroups.com
| -----Original Message-----
| From: vim...@googlegroups.com
| [mailto:vim...@googlegroups.com] On Behalf Of 703designs
| number of keystrokes. I suppose I could map Ctrl+A to do the tedious
| "ggVG" to select all text...even so, while I've built up a good

Why not? I have a bunch of mappings in my .vimrc that lets me use the
shortcuts/mappings that are common to most windows software...

/H.


ggrothendieck

unread,
May 3, 2008, 2:18:24 PM5/3/08
to vim_use


On May 2, 10:20 pm, 703designs <thomasmal...@gmail.com> wrote:
> Constantly having to press "Esc" and "i" gets old quickly when you
> just want to do quick edits, and I have yet to find an alternative.
> I'm still editing slowly...I feel like I've
> given Vim a very fair shake; what am I doing wrong? Any tips to help
> me get further up to speed?

Try out cream:

http://cream.sf.net

which is a bunch of vim scripts that implement modeless editing
and other features while still using vim. Maybe that suits your
style better.


Bryan Ewbank

unread,
May 3, 2008, 5:03:59 PM5/3/08
to vim...@googlegroups.com
This may sound a bit "too old" or "elitist" - it's not intended to be
- but if you still notice which keys you are hitting (e.g., <esc> and
"i"), you're not over the learning curve.

For me, vim (vi from "way back") is intuitive because I just think
where the cursor is to go and it moves -- I don't think of the
individual keys any more, so much as "move it over there". The "3
lines down, 2 words and 4 letters left" is subconscious. Really.

The same way with editing, My thought process is "the word is wrong,
let me change it to `fred`". My fingers to the walking without
direction.

Once you get past the (first) learning curve and adapt to a modeful
editor, you won't notice the <esc> and "i" any more that emacs-heads
notice one finger always on <ctrl> or <alt> -- or how you move and
click the mouse to navigate web pages.

Hope this offers some encouragement!

-BryanE

Matt Wozniski

unread,
May 3, 2008, 5:15:45 PM5/3/08
to vim...@googlegroups.com
On Fri, May 2, 2008 at 10:54 PM, 703designs wrote:
>
> I've used TextMate for about eight months, and I've used Vim on and
> off over the past couple years. I've been using Vim nearly exclusively
> over the past six weeks, studying the commands closely when editing,
> but even as I've gotten comfortable with the commands that are
> supposed to be Vim's most powerful, I've seen no productivity gain
> worth mentioning. The reputation of Vim is that, once you get over the
> "learning curve", things are great, and I think that I've at least
> gotten over the first curve. I think that Emacs may end up catering
> more to my style, but I haven't really done much of anything with it.

I consider myself to now be a pretty good vim user, but 6 weeks wasn't
even the tip of the learning-to-use-a-modal-editor iceberg for me -
I'd say it took me around two years to really get to the point where
my fingers did the work without me thinking about what buttons to
press, and until you hit that point, a modeless editor is almost
certainly faster.

Just my $0.02.

~Matt

Linda W

unread,
May 3, 2008, 5:54:38 PM5/3/08
to vim...@googlegroups.com
Jeffrey 'jf' Lim wrote:
> i personally use 'imap jj <ESC>' when i'm lazy and want to avoid the
> "2-finger thing" (C-]),
---
How's that supposed to work? I was just in gvim(Win), did the imap
and went into insert, and tried a double 'j' press, and all I got
were two 'j's in the text. :-/

What am I missing?

but really, C-o (WOW!! I just learnt that!!!) is

---
Ditto...now if I can remember it.
Only 'down' was forgetting I was in insert mode again after the command, but
it's just habit.

Tony Mechelynck

unread,
May 3, 2008, 6:05:07 PM5/3/08
to vim...@googlegroups.com

I'd rather use a different {lhs}, preferably an F key: Ctrl-A (in Normal
mode) is useful to increment a number.

Yes, I know Ctrl-A is "Select All" in most other GUIs but Vim is older
than that convention, and trying to enforce it in Vim (as well as Ctrl-C
for Copy rather than Interrupt, Ctrl-V for Paste rather than Block
Visual (from Normal) or Literalize (from Insert), Ctrl-X for Cut rather
than Decrement, Ctrl-Z for Undo rather than Suspend, etc.) led to the
"mswin.vim" script of ill repute, which prevented countless Windows
users from learning Vim smoothly.

Best regards,
Tony.
--
Slurm, n.:
The slime that accumulates on the underside of a soap bar when
it sits in the dish too long.
-- Rich Hall, "Sniglets"

Tony Mechelynck

unread,
May 3, 2008, 6:11:27 PM5/3/08
to vim...@googlegroups.com
On 03/05/08 23:54, Linda W wrote:
> Jeffrey 'jf' Lim wrote:
>> i personally use 'imap jj<ESC>' when i'm lazy and want to avoid the
>> "2-finger thing" (C-]),
> ---
> How's that supposed to work? I was just in gvim(Win), did the imap
> and went into insert, and tried a double 'j' press, and all I got
> were two 'j's in the text. :-/
>
> What am I missing?

It should be working, but maybe something is preventing it. If you're
using Vim 7 or later, you can try

:verbose map jj
:verbose map! jj

Best regards,
Tony.
--
There's little in taking or giving,
There's little in water or wine:
This living, this living, this living,
Was never a project of mine.
Oh, hard is the struggle, and sparse is
The gain of the one at the top,
For art is a form of catharsis,
And love is a permanent flop,
And work is the province of cattle,
And rest's for a clam in a shell,
So I'm thinking of throwing the battle --
Would you kindly direct me to hell?
-- Dorothy Parker

Java Bob

unread,
May 3, 2008, 6:36:52 PM5/3/08
to vim...@googlegroups.com
:imap jj <ESC>

works for me in gVIM(Win) but I am concerned that it will confuse me given
that j is the command that I use most frequently. In fact that concern
applies to all the keys. So I think I will stick with C-[ It is not so
hard now that I have got used to pressing the control key with the side of
my hand (UK keyboard).


> -----Original Message-----
> From: vim...@googlegroups.com [mailto:vim...@googlegroups.com]On

Linda W

unread,
May 3, 2008, 6:42:11 PM5/3/08
to vim...@googlegroups.com
Tony Mechelynck wrote:
> On 03/05/08 23:54, Linda W wrote:
>> Jeffrey 'jf' Lim wrote:
>>> i personally use 'imap jj<ESC>' when i'm lazy and want to avoid the
>>> "2-finger thing" (C-]),
>> ---
>> How's that supposed to work? I was just in gvim(Win), did the imap
>> and went into insert, and tried a double 'j' press, and all I got
>> were two 'j's in the text. :-/
>>
>> What am I missing?
>
> It should be working, but maybe something is preventing it. If you're
> using Vim 7 or later, you can try
>
> :verbose map jj
> :verbose map! jj
---
Using 7.1 gvim.
1st map said no mapping found
2nd map listed an 'i' in bottom line, left-most column, about 3 spaces, then
the letters 'jj', then maybe 10 spaces and the letters <Esc>

Weird. Seems straightforward. At least the Ctl-o worked...
-l

Linda W

unread,
May 3, 2008, 6:52:02 PM5/3/08
to vim...@googlegroups.com
Mark Wilden wrote:
> Maybe you should try
> using a "standard" editor (or even emacs) for a while to see if Vim is
> really for you?
===
Standard? You mean a standard like POSIX vi w/o the vim
enhancements? Or what'cha talking about?

Mark Wilden

unread,
May 3, 2008, 7:13:42 PM5/3/08
to vim...@googlegroups.com

I meant an editor that uses the standard UI for the OS. For example,
TextEdit for Macs or Notepad for Windows.

///ark

Michael Henry

unread,
May 4, 2008, 7:35:07 AM5/4/08
to vim...@googlegroups.com
Tony Mechelynck wrote:
> On 03/05/08 15:49, Hugo Ahlenius wrote:
>
>> | -----Original Message-----
>> | From: vim...@googlegroups.com
>> | [mailto:vim...@googlegroups.com] On Behalf Of 703designs
>> | number of keystrokes. I suppose I could map Ctrl+A to do the tedious
>> | "ggVG" to select all text...even so, while I've built up a good
>>
>> Why not? I have a bunch of mappings in my .vimrc that lets me use the
>> shortcuts/mappings that are common to most windows software...
>>
>> /H.
>>
>
> I'd rather use a different {lhs}, preferably an F key: Ctrl-A (in Normal
> mode) is useful to increment a number.
>
I use Alt-a, Alt-x, Alt-c, and Alt-v for "select all", "cut", "copy",
and "paste". This works well in gvim, but not in console-mode vim
because of console vim's limitations in mapping Alt-<any key> in
general. Still, for most of my editing sessions, I'm using gvim anyway,
so it's not a large limitation for me. In console-mode vim, I can
always use the "+ prefix before a yank or delete operation if I need
clipboard operations. These mappings are memorable for me, and as a
side benefit the physical keys involved are the same as those on OS X.
Apple computers use a modifier key called "Command" in many of the same
circumstances that Windows and Linux use the "Control" key. On OS X,
Command-a, Command-x, Command-c, and Command-v are the "select all",
"cut", "copy", and "paste" operations. Apple has chosen to put their
"Command" key in the same physical location as the "Alt" key on PCs, so
pressing Command-c on an Apple involves the same physical keys as
pressing Alt-c on a PC.

Michael Henry

Jean-Rene David

unread,
May 4, 2008, 8:31:22 AM5/4/08
to vim...@googlegroups.com
Hello,

My overall reaction to your question is: post the
actual commands that you repeat most often. Most
likely there is a way to do them more efficiently.

One of the strong points of vim is *precisely*
that whatever it is you do repeatedly can be
accelerated by shortcuts and automation.

This list is really helpful, but posting vague
question will only generate vague replies.

* 703designs [2008.05.02 22:30]:


> Constantly having to press "Esc" and "i" gets
> old quickly when you just want to do quick
> edits, and I have yet to find an alternative.

What "quick edits"?

You've already got answers involving <C-O> and
<C-]>.

Also see:

:h ins-special-keys
:h ins-special-special

> I suppose I could map Ctrl+A to do the tedious
> "ggVG" to select all text...

You want to select all text to do what exactly?

Lots of Ex-commands take a range of lines to act
on. In that case, the whole file is usually
specified with '%', which really isn't that
tedious.

I don't remember the last time I needed to "select
all text".

> I'm still editing slowly...

If you're still editing slowly, something is
missing from your repertoire of commands/habits.

> I feel like I've given Vim a very fair shake;
> what am I doing wrong?

From what you write, you're not doing *anything*
wrong. Quite the opposite: you've read the docs,
switched to using vim only, and posted to this
list ;-).

Perhaps you underestimate the learning curve...
But my advice is: post more specific questions.

--
JR

Mark Wilden

unread,
May 4, 2008, 10:56:00 AM5/4/08
to vim...@googlegroups.com
On May 4, 2008, at 5:31 AM, Jean-Rene David wrote:

> This list is really helpful, but posting vague
> question will only generate vague replies.

On the contrary - I think this thread has generated many interesting
(and specific) messages.

> I don't remember the last time I needed to "select
> all text".

"Selecting all" is actually so common that two major OSs devote keys
specifically to that purpose.

///ark

Mark S.

unread,
May 4, 2008, 3:33:34 PM5/4/08
to vim_use


On May 2, 11:24 pm, "John Beckett" <johnb.beck...@gmail.com> wrote:
> 703designs wrote:
keys on the three main rows:
>
> http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
>

That's pretty neat.

When I was learning E... er, some other editor, I found a trifold
cheat sheet on the net. I printed it out, and its been near my
keyboard for about a decade now. Later I bought a book that had a
similar tri-fold sheet in it, but was not nearly as good.

I'm wondering, is there a sheet like that for vim somewhere on the
net?

I do have the O'Reilly VI pocket book, but its awkward to using,
paging past all those other editors to get to the reference I need.

-- Mark

John Beckett

unread,
May 4, 2008, 10:11:49 PM5/4/08
to vim...@googlegroups.com
Mark S. wrote:
>> http://www.viemu.com/a_vi_vim_graphical_cheat_sheet_tutorial.html
>
> That's pretty neat.
>
> When I was learning E... er, some other editor, I found a
> trifold cheat sheet on the net. I printed it out, and its
> been near my keyboard for about a decade now. Later I bought
> a book that had a similar tri-fold sheet in it, but was not
> nearly as good.
>
> I'm wondering, is there a sheet like that for vim somewhere
> on the net?

There are a couple mentioned here (I think):
http://vim.wikia.com/wiki/Vim_documentation

What I would recommend however, is studying the page in the first link above. In
Vim, use help to get more info (yes, I know it's a bit abrupt, but you get used to
it). For example, for 'c':
:help c

That refers to 'motion' which you can double-click, or put the cursor on it and
press Ctrl-] (and Ctrl-t to return).

John

Michael Henry

unread,
May 4, 2008, 7:46:13 AM5/4/08
to vim...@googlegroups.com
I'm *sure* he must be talking about Ed.

Ed is the standard text editor.

Want proof?
http://www.gnu.org/fun/jokes/ed.msg.html

:-)

Michael Henry

Jeffrey 'jf' Lim

unread,
May 5, 2008, 12:55:03 AM5/5/08
to vim...@googlegroups.com

it should work then. Perhaps (although i imagine this'll be unlikely) you're just typing your 'j's too slowly? Thing about the imap is, vim needs to be able to understand that you might legitimately want to (and this applies for other imap "triggers" as well) type two consecutives 'j's in a text. To solve this problem, there is a "timeout" value after which if you press the 2nd letter for an 'imap' combination, the imap will not get triggered.... (use 'set timeoutlen', btw - default is 1000ms, or 1 sec)

-jf

Mark S.

unread,
May 5, 2008, 1:04:45 AM5/5/08
to vim_use
> it should work then. Perhaps (although i imagine this'll be unlikely) you're
> just typing your 'j's too slowly? Thing about the imap is, vim needs to be
> able to understand that you might legitimately want to (and this applies for
> other imap "triggers" as well) type two consecutives 'j's in a text. To
> solve this problem, there is a "timeout" value after which if you press the
> 2nd letter for an 'imap' combination, the imap will not get triggered....
> (use 'set timeoutlen', btw - default is 1000ms, or 1 sec)
> ....
> > > :verbose map jj
> > > :verbose map! jj

Shouldn't it be

:verbose imap jj

?

-- Mark

Mark Wilden

unread,
May 5, 2008, 1:12:58 AM5/5/08
to vim...@googlegroups.com
On May 4, 2008, at 4:46 AM, Michael Henry wrote:

> I'm *sure* he must be talking about Ed.
>
> Ed is the standard text editor.
>
> Want proof?
> http://www.gnu.org/fun/jokes/ed.msg.html
>
> :-)

Actually, back in the late '80s, I was something of a guru with edlin,
the MS-DOS line editor that everyone was guaranteed to have available.
I talked more than one secretary through editing AUTOEXEC.BAT with it
over the phone. :)

///ark

Mark S.

unread,
May 5, 2008, 1:14:46 AM5/5/08
to vim_use


On May 4, 7:11 pm, "John Beckett" <johnb.beck...@gmail.com> wrote:

> There are a couple mentioned here (I think):http://vim.wikia.com/wiki/Vim_documentation
>
> What I would recommend however, is studying the page in the first link above. In
> Vim, use help to get more info (yes, I know it's a bit abrupt, but you get used to
> it). For example, for 'c':
> :help c
>
> That refers to 'motion' which you can double-click, or put the cursor on it and
> press Ctrl-] (and Ctrl-t to return).

But what if I was looking for information on editing a program in
'c' ? ;-)

Never mind. Thanks for the link -- think I found a reference card that
may work. Now if I can get my decrepit printer to pump it out.

The keyboard tutorial page is very nice, but its not task oriented,
which is how most people will proceed. If I already know that 'c'
starts a change, then I wouldn't need the keyboard layout. Usually its
the other way around: "What keyboard sequence will allow me to start a
change?"

Thanks again,
Mark

azymuth

unread,
May 5, 2008, 6:12:14 AM5/5/08
to vim_use
On the "select all" issue, what are the most efficient way of copying
or deleting all the lines in a file. I have previously been using
ggVGd or perhaps :g/.*/d and similar for yanking. I'm sure there are
better ways.

Tim Chase

unread,
May 5, 2008, 6:23:10 AM5/5/08
to vim...@googlegroups.com
> On the "select all" issue, what are the most efficient way of copying
> or deleting all the lines in a file. I have previously been using
> ggVGd or perhaps :g/.*/d and similar for yanking. I'm sure there are
> better ways.

For such, I usually use

:%y
:%d

or, since the Ex yank/delete commands can take a register, this
is often done as

:%y+
:%d+

(sometimes using "*" instead of "+" as my target register) to put
the file in the system clipboard. It's short to type, and is
tweakable on the fly--such that if I just want from the current
line to the end of the file, I can use

:,$y+

or from the beginning to the current line:

:1,.d*

If Ex commands aren't your thing, you don't actually need to use
Visual mode for what you're doing:

ggdG
ggyG

will delete/yank the whole file.

-tim


Tony Mechelynck

unread,
May 5, 2008, 9:12:05 AM5/5/08
to vim...@googlegroups.com

See ":help mapmode-ic". ":map!" applies to both Insert/Replace and
Command-line modes, like ":map" applies to Normal, Visual and
Operator-pending. Thus using ":map" both with and without bang applies
to all modes.

Best regards,
Tony.
--
Speak roughly to your little boy,
And beat him when he sneezes:
He only does it to annoy
Because he knows it teases.

Wow! wow! wow!

I speak severely to my boy,
And beat him when he sneezes:
For he can thoroughly enjoy
The pepper when he pleases!

Wow! wow! wow!
-- Lewis Carrol, "Alice in Wonderland"

Tony Mechelynck

unread,
May 5, 2008, 9:21:44 AM5/5/08
to vim...@googlegroups.com
On 05/05/08 07:14, Mark S. wrote:
[...]

> The keyboard tutorial page is very nice, but its not task oriented,
> which is how most people will proceed. If I already know that 'c'
> starts a change, then I wouldn't need the keyboard layout. Usually its
> the other way around: "What keyboard sequence will allow me to start a
> change?"
>
> Thanks again,
> Mark

Well, ":help change" brings you to the help for the ":change"
ex-command, which is maybe not what you were looking for; however
looking at the status line shows that you're in a helpfile named
"change.txt" -- that might be interesting. Hit gg or, if you don't yet
know about that very useful movement, drag the scrollbar thumb all the
way to the top; and you'll see the table of contents of that helpfile
about making various kinds of changes.

Best regards,
Tony.
--
"I argue very well. Ask any of my remaining friends. I can win an
argument on any topic, against any opponent. People know this, and
steer clear of me at parties. Often, as a sign of their great respect,
they don't even invite me."
-- Dave Barry

Tony Mechelynck

unread,
May 5, 2008, 9:35:24 AM5/5/08
to vim...@googlegroups.com

The problem with Alt-letter is that Vim doesn't distinguish them from
[letter + 0x80] so Alt-a is á (a-acute), Alt-c is ã (a-tilde), Alt-v is
ö (o-umlaut) and Alt-x is ø (o-slash). Depending on which language(s)
you use, that might be a problem in Insert mode.

On Apple, maybe Command-c involves the same physical key as Alt-c on a
PC but I thought Command-c did more or less the same as Ctrl-c on a PC,
and that the close (functional) equivalent of Alt-c was Option-c ?


Best regards,
Tony.
--
Today is the tomorrow you worried about yesterday

Mark S.

unread,
May 5, 2008, 11:27:43 AM5/5/08
to vim_use
In relation to the original advice given to the OP, when I tested it
by creating:

imap jj <esc>

and then tried :

:verbose map jj

There is nothing on the output line.

If I try:

:verbose imap jj

the correct mapping appears on the output line. The OP was advised to
look at

:verbose map jj

which will indeed show nothing if her/his system is like mine.

-- Mark

On May 5, 6:12 am, Tony Mechelynck <antoine.mechely...@gmail.com>
wrote:

Gene Kwiecinski

unread,
May 5, 2008, 6:44:04 PM5/5/08
to vim...@googlegroups.com
>>I'm still editing slowly...

>If you're still editing slowly, something is
>missing from your repertoire of commands/habits.

That could very well be it. "Learning vi|vim|*" isn't simply
translating one set of commands for another, ie, it ain't simply riding
the 'x' key instead of riding the <del> key to delete an entire line of
text, one char at a time (urg...). It means "thinking in 'vi'" in terms
of the command-set, like learning '14dd', visuals, marks, etc., to do
editing-in-bulk. If his "lots of little commands" might be to, eg,
switch the case of every word in a title-line, *maybe* he's doing
something like

x
iT<esc>
w
x
iN<esc>

/ad nauseam/, until the last word, instead of a single ':s///' command
using '\u' on each word, and getting it done in one shot. Done the
former way, yeah, there ain't all that much "gained" by switching to
'vim', etc.

It's analogous to "speeding up" a program by squeezing every byte and
clock-cycle out of routines that still use a bad algorithm; changing
the algorithm itself can result in a dramatic speed-up. Eg, think of
generating CRCs by individual bit-shifts and XORs, vs using a simple
lookup table.

Tony Mechelynck

unread,
May 5, 2008, 9:07:00 PM5/5/08
to vim...@googlegroups.com
On 05/05/08 17:27, Mark S. wrote:
> In relation to the original advice given to the OP, when I tested it
> by creating:
>
> imap jj<esc>
>
> and then tried :
>
> :verbose map jj
>
> There is nothing on the output line.
>
> If I try:
>
> :verbose imap jj
>
> the correct mapping appears on the output line. The OP was advised to
> look at
>
> :verbose map jj
>
> which will indeed show nothing if her/his system is like mine.
>
> -- Mark

The OP was advised to look at both

:verbose map jj
:verbose map! jj

and he found his imap in the output of the latter, which was the
expected result. The reason I told him to check both was in case he has
mistyped it without the initial i.


Best regards,
Tony.
--
Niklaus Wirth has lamented that, whereas Europeans pronounce his name
correctly (Ni-klows Virt), Americans invariably mangle it into
(Nick-les Worth). Which is to say that Europeans call him by name, but
Americans call him by value.

Michael Henry

unread,
May 6, 2008, 7:24:29 AM5/6/08
to vim...@googlegroups.com
Tony Mechelynck wrote:
> On 04/05/08 13:35, Michael Henry wrote:
>
>> I use Alt-a, Alt-x, Alt-c, and Alt-v for "select all", "cut", "copy",
>> and "paste".
>>
>> Michael Henry
>>
> The problem with Alt-letter is that Vim doesn't distinguish them from
> [letter + 0x80] so Alt-a is á (a-acute), Alt-c is ã (a-tilde), Alt-v is
> ö (o-umlaut) and Alt-x is ø (o-slash). Depending on which language(s)
> you use, that might be a problem in Insert mode.
>
I confess that I don't have a full grasp on the drawbacks to using
Alt+letter mappings (other than a general understanding that they
interact badly with extended characters). I've mainly been able to
ignore these problems, at least under gvim, as I haven't had the need in
general to enter non-ASCII characters. For my purposes, it's well worth
the trade-off in order to use Alt+letter mappings, but if I'd had a
better grasp of the drawbacks, I'd have mentioned them in my posting.

I've been following the other postings regarding possible changes to Vim
to better handle modifier keys like Alt. Hopefully in the future Vim
will be able to distinguish Alt+letter from accented letters and the
like. I'm sure there will always be terminals that can't provide enough
information to Vim, but hopefully that won't be enough to hold back the
terminals that can. I'm looking forward to the day when I can map
Alt-Enter successfully. Even on Gvim, the following doesn't work for me
(yet :-)):

:imap <M-Enter> <Ctrl-o>o


> On Apple, maybe Command-c involves the same physical key as Alt-c on a
> PC but I thought Command-c did more or less the same as Ctrl-c on a PC,
> and that the close (functional) equivalent of Alt-c was Option-c ?
>

Yes, on OS X there are four modifier keys: Shift, Control, Option, and
Command. They are physically in the same positions as Shift, Control,
Windows key, and Alt on a standard U.S. 104-key keyboard. Shift and
Control have the same meaning on both platforms. On OS X, the Option
key (also labeled Alt/Option on some keyboards) is the same as the
Windows Alt key semantically. The Command key on OS X has no direct
equivalent on Windows, and the Windows key has no direct equivalent on
OS X. As a system-wide convention on Windows, Ctrl-C means "Copy"; on
OS X, the system-wide convention is that Command-C means "Copy".
Happily, Vim lets me arbitrarily map Alt-C on Windows and Command-C on
OS X. I choose to map them both to mean "Copy" so I can press the same
physical keys on either platform. Ideally, there would be some simple
mapping I could perform system-wide that would let me put the physical
keys in the same place on both platforms. Unfortunately, it's not
really possible to do that in a satisfactory way. It's possible to
trade the positions of the Control and Command keys on OS X, for
example. That way, pressing the physical Control key with "C" would
actually generate Command-C, which would be the "Copy" operation
expected by a Windows touch typist. Unfortunately, in a terminal
emulator the Ctrl-C operation for breaking a running program would no
longer be in the expected position. The user would need to press the
physical Command key along with "C" to get a true Ctrl-C. Similarly,
Emacs-style editing keys integrated throughout OS X would no longer work
as expected. Ctrl-a would normally move to start of line (in Bash, for
example, as well as in the standard text edit box on OS X). With the
Control and Command keys exchanged, one would need to press Command-a
for the same purpose.

So in my .vimrc, I test whether I'm running on a mac and map accordingly:

if has("mac")
imap <D-c> <C-Insert>
else
imap <M-C> <C-Insert>
endif

(The "D" modifier means "Command" on OS X.)

I probably would have chosen the Windows convention and mapped OS X's
Ctrl-C to the "Copy" operation, but I'd like to retain Vim's meaning for
these control characters.

Michael Henry

Reply all
Reply to author
Forward
0 new messages