Fork me on GitHub

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


D also deletes to end of line


I use c i o to change a whole symbol. it works even if you're not at the beginning of the symbol

πŸ‘ 4

change in ( c i (, change β€œaround” ( c a (

πŸ‘ 8
Sam H10:10:00

yeah I like the {c|d} {i|a} <{w | ( | [ }> type of modifying

Sam H10:10:53

also I’ve looked at a few chapters of a while ago and it seemed really good. I really need to dedicate time to improving though 😞

πŸ‘ 4

@jr0cket maybe instead of delete word d w`` you want something like d i|a w?


delete to end of line d $ = D?

πŸ‘Œ 4

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.

πŸ‘ 4

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.


and an every growing quick reference... but its tricky to learn all these at once πŸ™‚


I like using zt, zz, and zb to pull the current line to the top/middle/bottom of the screen.

❀️ 4

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.

metal 4

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

    (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


Oh that one is actually useful too. Thanks πŸ™‚


Let me give it a shot.


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.


Okay I got it.


I had an error in my user-config that I didn't notice.


So I don't think it was evaluating the user-config properly.


Thanks for the help.


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


What I'd like is that if I am inside of the outer sexp then newline in the sexp I am in, if I am outside of the outside sexp then evaluate.


Maybe too complicated? I don't know. haha


I will play with the new keybinding to see how comfortable it feels to evaluate on C-Ret after some time with it.