SORU
11 Mart 2010, PERŞEMBE


Satır/bölge yukarı ve aşağı hareket emacs

seçili bölge veya hattı varsa, seçim varsa hayır () yukarı veya aşağı emacs içinde taşımak için en kolay yolu nedir biliyor musun? Eclipse gibi aynı işlevselliği (M-M-sınırlı) arıyorum.

Teşekkürler

CEVAP
11 Mart 2010, PERŞEMBE


Güncelleme:Reçel veya MELPA move-text paketi, aşağıdaki kodu almak için yükleyin.

Kullanıyorum, her iki bölge ve tek tek satırları üzerinde çalışır:

(defun move-text-internal (arg)
  (cond
   ((and mark-active transient-mark-mode)
    (if (> (point) (mark))
        (exchange-point-and-mark))
    (let ((column (current-column))
          (text (delete-and-extract-region (point) (mark))))
      (forward-line arg)
      (move-to-column column t)
      (set-mark (point))
      (insert text)
      (exchange-point-and-mark)
      (setq deactivate-mark nil)))
   (t
    (let ((column (current-column)))
      (beginning-of-line)
      (when (or (> arg 0) (not (bobp)))
        (forward-line)
        (when (or (< arg 0) (not (eobp)))
          (transpose-lines arg)
          (when (and (eval-when-compile
                       '(and (>= emacs-major-version 24)
                             (>= emacs-minor-version 3)))
                     (< arg 0))
            (forward-line -1)))
        (forward-line -1))
      (move-to-column column t)))))

(defun move-text-down (arg)
  "Move region (transient-mark-mode active) or current line
  arg lines down."
  (interactive "*p")
  (move-text-internal arg))

(defun move-text-up (arg)
  "Move region (transient-mark-mode active) or current line
  arg lines up."
  (interactive "*p")
  (move-text-internal (- arg)))


(global-set-key [M-S-up] 'move-text-up)
(global-set-key [M-S-down] 'move-text-down)

Bunu Paylaş:
  • Google+
  • E-Posta
Etiketler:

YORUMLAR

SPONSOR VİDEO

Rastgele Yazarlar

  • parlophone

    parlophone

    28 ŞUBAT 2006
  • TheScorpioTechno

    TheScorpioTe

    15 Aralık 2010
  • williamfitzsimmons

    williamfitzs

    14 Mart 2008