I had a discussion with a friend today about how to "split
lines effectively" in gvim.  The trick below came up and he
mentioned "yeah but I want something that will work in default
gvim without having to create a binding or macro."  I'm
curious why gvim doesn't have a single keystroke that does a
line split since it would make sense given the ability to join
lines (J).  Currently (as stated below) the only way I know
how to split a line is i<CR><Esc>

Well, creating a mapping isn't costly, and is even easy enough to
do that maint. doesn't really become a problem either.  Given
that vi/vim has umpteen keys for moving down a line ("k", "-",
and <CR>), I like to remap <CR> to do exactly as you describe:

        :nnoremap <cr> i<cr><esc>

The mapping is pretty easy to understand, doesn't tromp on a key
I otherwise use in normal-mode, and is short/sweet enough that
recreating it takes mere seconds (not like some complex and
convoluted ordeal).

In gvim you can do i<Del><Esc> or 0i<BS> to join lines. So the
need for (J) is superfluous.  Why is there no antithesis to J
for splitting lines?

That, I can't answer... :)  Perhaps because the
screen-cursor/virtual-cursor difference of falling in between
character, one would need/want an "insert a <CR> *before* the
cursor" (as above maps) and perhaps an "insert a <CR> *after* the
cursor".  Or maybe it's just <fiddler location="roof">tradition,
tradition!</fiddler> :)

-tim




Reply via email to