This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2018-10-19
Channels
- # 100-days-of-code (5)
- # announcements (1)
- # aws (1)
- # beginners (112)
- # cider (135)
- # cljdoc (6)
- # clojure (111)
- # clojure-dev (8)
- # clojure-italy (3)
- # clojure-nl (5)
- # clojure-sweden (3)
- # clojure-uk (152)
- # clojurescript (101)
- # datascript (14)
- # datomic (61)
- # editors (1)
- # emacs (29)
- # events (7)
- # figwheel (3)
- # figwheel-main (15)
- # fulcro (18)
- # funcool (2)
- # graphql (1)
- # juxt (2)
- # off-topic (51)
- # om (1)
- # overtone (28)
- # perun (2)
- # reagent (1)
- # reitit (6)
- # ring-swagger (5)
- # shadow-cljs (112)
- # spacemacs (49)
- # tools-deps (10)
- # unrepl (11)
- # yada (10)
I am working on a screencast for Vim editing techniques that are common for developers, e.g. simple transpose x p
, change word c w
, change region v (select) c
, comment line g c c
, comment region v (select) g c
, delete word d w
, delete to end of line d $
, surround with [] without spaces v s ]
, change surrounding ( to [ c s ( [
, transpose words M-t
(that may be Emacs keybinding), multi-replace with iedit and narrowing.
Any editing techniques you use? Or things you wish you could do easily?
Thanks
I use c i o
to change a whole symbol. it works even if you're not at the beginning of the symbol
also Iβve looked at a few chapters of https://pragprog.com/book/dnvim2/practical-vim-second-edition a while ago and it seemed really good. I really need to dedicate time to improving though π
@jr0cket maybe instead of delete word
d w`` you want something like d i|a w
?
same for change word?
because d w
will detele till end of word. not the word itself
I often surround things with y s <character> <motion>
instead of v ...
.
Relatedly, I use the %
motion a lot. (Scan forwards for next paren/bracket/brace and then jump to its match.)
Also most vimmers I know somehow don't know about the {
/`}` motions (jump to next/prev empty line), which I use all the time. Makes rearranging paragraphs and such really easy too. For example, { d } { P
will swap the current paragraph with the preceding one.
One more that should be an integral part of every vimmer's toolbox, but rarely is IMO, is .
(the repeat operator). You have to use vim a certain way (I would argue the right way, e.g. without arrow keys in insert mode) to make good use of it. But there's so much power there.
Also cool thing you can combine d | c | v | r with ace jump
Another couple I just thought of because I used them are the W
/`B` motions, which are like the lowercase versions except they jump between whitespace-delimited words only. Surprisingly useful.
Jumps to the end of the word
these are all excellent suggestions and helping make more use of Vim, feel free to keep sharing if you have them.
OK. >
and <
(indent and dedent) operators, which are also useful with the aforementioned }
/`{` motions.
=
(code-aware indenting) operator. Nice with the ap
(a paragraph) text object.
I've started defining a page about how to think in Vim https://practicalli.github.io/spacemacs/spacemacs-basics/speaking-vim.html
and an every growing quick reference... but its tricky to learn all these at once π https://practicalli.github.io/spacemacs/spacemacs-basics/vim-quick-reference.html
I like using zt
, zz
, and zb
to pull the current line to the top/middle/bottom of the screen.
And SPC v
in Spacemacs is nice to select whatever you're at. You can repeat v
at that point to widen the selection to the next biggest thing, etc.
zc
and zo
are useful to close and open folds, which can be a nice way of focusing on certain pieces of code.
Talking of code folds, anyone have preference over vim or origami style folds in Spacemacs. I think I am leaning towards vim style.
I never really tried to use origami style, but vim-style is what I cut my teeth on and I'm comfortable with them.
I am trying to use define-key to remap some keys in cider-repl-mode-map and I'm having a hard time to get spacemacs to load it on startup. Maybe I am not putting it in the right place. Inside of dotspacemacs/user-config I have the following
(progn
(require 'cider-repl)
(define-key cider-repl-mode-map (kbd "RET") #'cider-repl-newline-and-indent)
(define-key cider-repl-mode-map (kbd "C-<return>") #'cider-repl-return))
If I evaluate it manually it works, but it does not change the key binding when spacemacs loads. Any ideas?@jeremy642 you should use a hook.. let me dig out an example
(add-hook 'cider-repl-mode-hook
'(lambda ()
(define-key cider-repl-mode-map (kbd "<up>") 'cider-repl-previous-input)
(define-key cider-repl-mode-map (kbd "<down>") 'cider-repl-next-input)))
You can of course call a separate function rather than using the lambda
The hook will run when you first enter the cider-repl-mode
. You should just be able to evaluate .spacemacs and try it out in a new REPL.
I assume you are also putting the code inside the dotspacemacs/user-config
function
That didn't work. I loaded a new repl and ret evaluates. Up and down just move the cursor.
Interesting, I used the same code a few weeks ago and it worked.
Going to reload emacs. I ended up trying to eval it, run a new repl and it worked. So I'm getting confused on what's working and what's not.
Great. I am still investigating if this should be the default behaviour for the REPL buffer, with RET allowing multi-line editing and C-RET
being evaluation. It seems quite a few people are setting this in Spacemacs/Emacs