help-gnu-emacs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Move selection up, down


From: Chat
Subject: Re: Move selection up, down
Date: Tue, 19 Aug 2008 15:43:48 -0700
User-agent: Emacs Gnus

harven <address@hidden> writes:

> On Aug 19, 4:21 pm, "address@hidden" <address@hidden>
> wrote:
>> Hi,
>>
>> in Netbeans when you press M-S-up/M-S-down you move the selected text
>> up/down. When nothing is selected it moves the current line.
>>
>> With C-S-up/C-S-down you copy the selection up/down. When nothings is
>> selected it copies the current line up/down.
>>
>> Is such functionality available in emacs?
>>
>> Jiri Pejchal
>
> There are similar functionalities in emacs,
> although the bindings are different. For example, the command that
> transposes two
> consecutive lines is called transpose-lines and is bound to C-x C-t by
> default. Other transpose commands include transpose-region, transpose-
> char, transpose-paragraphs, transpose-words, transpose-sentences.
>
> You can also redefine such functionalities
> by hand using a bit of lisp code. For example,
> if I want to exchange two consecutive lines, I can define the
> following command:
>
>   (defun line-down ()
>    (interactive)
>    (save-excursion
>      (beginning-of-line)
>      (kill-line 1)
>      (next-line)
>      (yank))
>    (next-line))
>
> and bind it to C-S-down:
>
>   (global-set-key (kbd "C-S-<down>") 'line-down)
>
> This may convince you that new functionalities
> are easily added to emacs.
For simple things like this, reading the secion "emacs" -> "keyboard macros" in
M-x info also helps.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]