C-S-up and C-s-down

12 views
Skip to first unread message

David Gomes

unread,
Feb 12, 2012, 10:00:15 AM2/12/12
to v...@vim.org
I was wondering of how I can map Ctrl+Shift+Up to select all region above until next blank like, and Ctrl+Shift+Down to select all region below until next blank line.

These are very common shortcuts on Emacs, and any Gtk app. So I was wondering how I can get them on Vim.

Thanks!

--
David Gomes

Taylor Hedberg

unread,
Feb 12, 2012, 11:41:57 AM2/12/12
to vim...@googlegroups.com, v...@vim.org
David Gomes, Sun 2012-02-12 @ 15:00:15+0000:

> I was wondering of how I can map Ctrl+Shift+Up to select all region
> above until next blank like, and Ctrl+Shift+Down to select all region
> below until next blank line.

:noremap <C-S-Up> V'{j
:noremap <C-S-Down> V'}k

How's that?

Dotan Cohen

unread,
Feb 12, 2012, 11:48:51 AM2/12/12
to vim...@googlegroups.com, v...@vim.org

What is the ' for? I tried :help v_' and v' (to check ' in visual
mode) but there was no help for that, and ' in regular mode (marks)
does not seem relevant.

--
Dotan Cohen

http://gibberish.co.il
http://what-is-what.com

Taylor Hedberg

unread,
Feb 12, 2012, 11:54:53 AM2/12/12
to vim...@googlegroups.com, v...@vim.org
Dotan Cohen, Sun 2012-02-12 @ 18:48:51+0200:

> On Sun, Feb 12, 2012 at 18:41, Taylor Hedberg <tmhe...@gmail.com> wrote:
> > David Gomes, Sun 2012-02-12 @ 15:00:15+0000:
> >    :noremap <C-S-Up> V'{j
> >    :noremap <C-S-Down> V'}k
> >
> > How's that?
>
> What is the ' for? I tried :help v_' and v' (to check ' in visual
> mode) but there was no help for that, and ' in regular mode (marks)
> does not seem relevant.

You're right, it's unnecessary. The '} and '{ are automatic marks that
exist at the end and beginning of the current paragraph. But I
overlooked that you could just use the } and { motions instead.

Didn't have my coffee this morning... :)

David Gomes

unread,
Feb 14, 2012, 12:34:08 PM2/14/12
to vim...@googlegroups.com, v...@vim.org
That didn't really work, neither with nor without the parentheses.

Thanks!
--
David Gomes

Taylor Hedberg

unread,
Feb 14, 2012, 12:45:18 PM2/14/12
to vim...@googlegroups.com, v...@vim.org
David Gomes, Tue 2012-02-14 @ 17:34:08+0000:

> That didn't really work, neither with nor without the parentheses.

Do you really mean parentheses? The commands I posted don't use
parentheses; those are braces. The things you use to delimit code blocks
in C-like languages. If you actually used parentheses, then no, it won't
work as intended.

David Gomes

unread,
Feb 14, 2012, 12:50:57 PM2/14/12
to vim...@googlegroups.com, v...@vim.org
No, my mistake, this is what I put:

" Select text with keyboard like in Gtk Apps
:noremap <C-S-Up> V{j
:noremap <C-S-Down> V}k

--
David Gomes

Taylor Hedberg

unread,
Feb 14, 2012, 12:56:24 PM2/14/12
to vim...@googlegroups.com, v...@vim.org
David Gomes, Tue 2012-02-14 @ 17:50:57+0000:

> No, my mistake, this is what I put:
>
> " Select text with keyboard like in Gtk Apps
> :noremap <C-S-Up> V{j
> :noremap <C-S-Down> V}k

Are you using GVim or terminal Vim? A lot of terminals won't deal with
modified cursor keys very well. If that's the case for you, you might
have to use a different key combination for the mapping.

Other than that, I don't know what to tell you. It works for me, with
the small exception that it gets confused if you use <C-S-Up> at the
very top of the buffer or <C-S-Down> at the very bottom. That could be
handled by having the mappings call a function which detects those
special cases and handles them differently (basically, by omitting the
`k` and `j` at the end of the normal-mode commands).

David Gomes

unread,
Feb 14, 2012, 1:01:07 PM2/14/12
to vim...@googlegroups.com, v...@vim.org
On Gvim it works indeed, thanks!
--
David Gomes

Christian Brabandt

unread,
Feb 14, 2012, 1:17:41 PM2/14/12
to vim...@googlegroups.com, v...@vim.org
Hi David!

Please don't top post.


On Di, 14 Feb 2012, David Gomes wrote:

> On Gvim it works indeed, thanks!

The problem with terminal vim has already been pointed out to you last
time. It is mentioned in the faq. May be you should read it?

regards,
Christian

Reply all
Reply to author
Forward
0 new messages