Select Text without jump between Insert Mode / Visual Mode

1,519 views
Skip to first unread message

Peter Holm

unread,
Dec 26, 2007, 12:13:54 PM12/26/07
to v...@vim.org
Hi.
I want to remap my keys so far as possible to never leave the insert mode.
Anyone that can tell me what i should put in .vimrc to map:

<shift>+<arrowkey> <ctrl>+<ins> (typeing operation, then i choose to
paste) <shift>+<ins>
as
<esc> <v> <arrowkey> (to hilightt text) <y> <I> (typeing operation,
then i choose to paste) <esc> <p>
I can't find it in the msvin.vim, and i didn't find it on google.

/Peter

Martin K. Schreder

unread,
Dec 26, 2007, 5:45:13 PM12/26/07
to vim...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Well, you could do it like this:

" switch to visual mode and extend selection upwards
:imap <S-Up> <esc>v<Up>
" make sure the same key combination works in visual mode
:vmap <S-Up> <Up>

" do the same for other arrow keys
:imap <S-Down> <esc>v<Down>
:vmap <S-Down> <Down>
:imap <S-Left> <esc>v<Left>
:vmap <S-Left> <Left>
:imap <S-Right> <esc>v<Right>
:vmap <S-Right> <Right>

" C-Insert yanks in vis mode and goes back to insert
" Remapping C-Insert does not work for me in terminal
:vmap <C-Ins> y<esc>i

" paste using S-Ins
:imap <S-Ins> <esc>pi
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHctl5jzC7shOa4SARApSkAJ96Nunsj7uUFUazw+0lazvYCEwgpACgg2kw
YNGIAgoUtfO88kHIQRH8KLE=
=ufj/
-----END PGP SIGNATURE-----

Martin K. Schreder

unread,
Dec 26, 2007, 5:48:20 PM12/26/07
to vim...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

... or you could check out how cream does it: http://cream.sourceforge.net/

-


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHcto0jzC7shOa4SARAsd+AKCnSOL6f0IuEtolqnTue3dp4nYGKwCfe14w
1WpDYFUiVkyeibQjY0Xb8bk=
=U/uc
-----END PGP SIGNATURE-----

Ben Schmidt

unread,
Dec 26, 2007, 6:04:02 PM12/26/07
to vim...@googlegroups.com

If you generally want to stay in insertmode, you may just want to

:set insertmode

or use 'easy (g)Vim' by starting as

(g)vim -y

or using the shortcut the MS Windows installer creates that does that.

See

:help 'insertmode'
:help -y
:help evim-keys

I think, though, it would be safe to say most people on this list (including me)
would recommend against doing this. Vim is designed as a modal editor and works
best that way. But you may find bits of evim.vim, etc. useful, I guess.

You may also be more interested in select mode than visual mode, see

:help Select

Ben.


Send instant messages to your online friends http://au.messenger.yahoo.com

Peter Holm

unread,
Dec 26, 2007, 7:10:11 PM12/26/07
to vim...@googlegroups.com
Thank you for your ansver.
It didn't work for me.

I pasted your solution to my .vimrc and then i restarted vim.
After that - either with vim in xterm or gvim,, when i use
<shift+left> key i can highlight one char, and the same with the
<shift+right> key.
With the <shift+down> i can highlight one row, and the same with <shift+up>
In console there is no difference.

Maybe i did something wrong.?

2007/12/26, Martin K. Schreder <mar...@schreder.nu>:

Martin K. Schreder

unread,
Dec 27, 2007, 3:31:27 AM12/27/07
to vim...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Peter Holm wrote:
> Thank you for your ansver.
> It didn't work for me.
>
> I pasted your solution to my .vimrc and then i restarted vim.
> After that - either with vim in xterm or gvim,, when i use
> <shift+left> key i can highlight one char, and the same with the
> <shift+right> key.
> With the <shift+down> i can highlight one row, and the same with <shift+up>
> In console there is no difference.
>
> Maybe i did something wrong.?
>

Hmm, that's strange. Make sure you are not using compatible mode. :set
nocompatible. As I said before C-Ins only works in gvim, but the rest
of the mappigs work for me both in gvim and xterm. All of them are
pretty straight forward. imap is insert mode mapping and vmap is
selection mode mapping.

>


-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHc2LejzC7shOa4SARAnTxAKCQJmcpuf+lSWeDYuWhg2gUYVUpigCfZLNK
k5gZAZopBcsawey1QP7FjAk=
=QqiU
-----END PGP SIGNATURE-----

Peter Holm

unread,
Dec 31, 2007, 2:26:23 PM12/31/07
to vim...@googlegroups.com
After running apt-get upgrade i t seems to work in gvim and in vim
under an xterm, but still not in a console. But that doesn't matter
that much to me right now.

2007/12/27, Martin K. Schreder <mar...@schreder.nu>:


--
Med Vänlig Hälasning, my Best Regards
/Peter Holm

DataRepair

Reply all
Reply to author
Forward
0 new messages