aboutsummaryrefslogtreecommitdiff
path: root/bard-elisp/bard-editing.el
blob: 1e34eeafe648f0d5d5dd48ccf4438a4aa03243eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
;;; bard-editing.el --- My custom editing functions and keybinds -*- lexical-binding: t -*-

;; Author: BardofSprites
;; Maintainer: BardofSprites
;; Version: 0.1.0
;; Package-Requires: ((emacs "28.2"))

;; This file is not part of GNU Emacs

;; This program is free software: you can redistribute it and/or modify
;; it under the terms of the GNU General Public License as published by
;; the Free Software Foundation, either version 3 of the License, or
;; (at your option) any later version.

;; This program is distributed in the hope that it will be useful,
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;; GNU General Public License for more details.

;; You should have received a copy of the GNU General Public License
;; along with this program.  If not, see <https://www.gnu.org/licenses/>.


;;; Commentary:
;; Custom editing functions with intended use of my personal GNU Emacs configuration
;;; Code:

;; Surround region with character
(defun bard/wrap-text-with-markers (start-marker end-marker marker)
  "Surround marked text with any character."
  (interactive "r\nsEnter marker (e.g., \"): ")
  (save-excursion
    (goto-char end-marker)
    (insert marker)
    (goto-char start-marker)
    (insert marker)))

(global-set-key (kbd "C-c s") 'bard/wrap-text-with-markers)

(defun bard/copy-current-line ()
  "Copy the current line."
  (interactive)
  (let ((line-text (buffer-substring (line-beginning-position) (line-end-position))))
    (kill-new line-text)
    (message "Copied current line")))

(global-set-key (kbd "C-c l") 'bard/copy-current-line)

;; Multiple cursors
(global-set-key (kbd "C-S-c C-S-c") 'mc/edit-lines)
(global-set-key (kbd "C->")         'mc/mark-next-like-this)
(global-set-key (kbd "C-<")         'mc/mark-previous-like-this)
(global-set-key (kbd "C-c C-<")     'mc/mark-all-like-this)
(global-set-key (kbd "C-\\")        'mc/skip-to-next-like-this)
(global-set-key (kbd "C-:")         'mc/skip-to-previous-like-this)

;;; bard-editing.el ends here