Fix some movement, including a better start to visual

Why not have `v` (when programming), select the entire symbol?
This commit is contained in:
Howard Abrams 2023-04-06 22:00:12 -07:00
parent 7a5ccc996b
commit b7a35fe1dc
2 changed files with 24 additions and 6 deletions

View file

@ -360,7 +360,7 @@ What text objects are known?
- ~~ :: a string, surround by quotes, also ~`~ for backticks - ~~ :: a string, surround by quotes, also ~`~ for backticks
- ~)~ :: parenthesis, also ~}~ and ~]~, see ~g~ - ~)~ :: parenthesis, also ~}~ and ~]~, see ~g~
- ~x~ :: within a brace, paren, etc., with the [[Better Parenthesis with Text Object][my extensions below]], see ~b~ and ~f~ for similar functionality. - ~x~ :: within a brace, paren, etc., with the [[Better Parenthesis with Text Object][my extensions below]], see ~b~ and ~f~ for similar functionality.
- ~d~ :: a /defun/, or code block, similar to ~p~. - ~f~ :: a /defun/, or code block, see [[file:ha-programming.org::*Evil Text Object from Tree Sitter][definition here]].
- ~i~ :: indention area, for YAML and Python, with the [[Text Objects based on Indentation][evil-indent-plus]] package - ~i~ :: indention area, for YAML and Python, with the [[Text Objects based on Indentation][evil-indent-plus]] package
- ~t~ :: an HTML tag - ~t~ :: an HTML tag
- ~c~ :: for comments - ~c~ :: for comments
@ -1541,9 +1541,20 @@ Magnar Sveen's [[https://github.com/magnars/expand-region.el][expand-region]] pr
(use-package expand-region (use-package expand-region
:bind ("C-=" . er/expand-region) :bind ("C-=" . er/expand-region)
:config
(defun ha-start-region ()
"Increase the region when on special characters."
(interactive)
(if (looking-at (rx (any "{}()[]")))
(call-interactively 'er/expand-region)
(evil-visual-state)))
:general :general
(:states 'normal "v" 'ha-start-region)
;; Use escape to get out of visual mode, but hitting v again expands the selection. ;; Use escape to get out of visual mode, but hitting v again expands the selection.
(:states 'visual "v" 'er/expand-region)) (:states 'visual
"v" 'er/expand-region
"V" 'er/contract-region))
#+end_src #+end_src
* Working Layout * Working Layout
While editing any file on disk is easy enough, I like the mental context switch associated with a full-screen window frame showing all the buffers of a /project task/ (often a direct link to a repository project, but not always). While editing any file on disk is easy enough, I like the mental context switch associated with a full-screen window frame showing all the buffers of a /project task/ (often a direct link to a repository project, but not always).

View file

@ -121,6 +121,9 @@ My primary use-case is for its refactoring and other unique features. For instan
(use-package lispy (use-package lispy
:config :config
(evil-define-key 'normal emacs-lisp-mode-map (evil-define-key 'normal emacs-lisp-mode-map
;; Use C-SPC to mark single letter, as these seem to be nicer expansions:
"v" 'lispy-mark-symbol ; Mark larger section at first?
"M-v" 'lispy-mark ; Mark entire s-expression
"g f" 'lispy-ace-paren "g f" 'lispy-ace-paren
"g F" 'lispy-ace-symbol) "g F" 'lispy-ace-symbol)
@ -173,7 +176,7 @@ Use the ~>~ key to /slurp/ in outside objects into the current expression… in
:hook ((emacs-lisp-mode lisp-mode) . lispyville-mode)) :hook ((emacs-lisp-mode lisp-mode) . lispyville-mode))
#+end_src #+end_src
Now Now we need to define additional key movements:
#+begin_src emacs-lisp #+begin_src emacs-lisp
(use-package lispyville (use-package lispyville
:config :config
@ -202,7 +205,11 @@ Now
"(" 'lispyville-previous-opening "(" 'lispyville-previous-opening
")" 'lispyville-next-closing ")" 'lispyville-next-closing
"{" 'lispyville-backward-up-list "{" 'lispyville-backward-up-list
"}" 'lispyville-next-opening) "}" 'lispyville-next-opening
"[ f" 'lispyville-beginning-of-defun
"] f" 'lispyville-beginning-of-next-defun
"] F" 'lispyville-end-of-next-defun)
;; Visually high-light a region, just hit `(' to wrap it in parens. ;; Visually high-light a region, just hit `(' to wrap it in parens.
;; Without smartparens, we need to insert a pair of delimiters: ;; Without smartparens, we need to insert a pair of delimiters: