Fork me on GitHub
#spacemacs
<
2018-10-19
>
practicalli-johnny09:10:31

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

euccastro00:10:53

D also deletes to end of line

euccastro00:10:53

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

πŸ‘ 4
jahson09:10:51

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 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 😞

πŸ‘ 4
kirill.salykin12:10:18

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

kirill.salykin12:10:43

delete to end of line d $ = D?

πŸ‘Œ 4
kirill.salykin12:10:22

same for change word?

kirill.salykin12:10:48

because d w will detele till end of word. not the word itself

jeff.terrell13:10:21

I often surround things with y s <character> <motion> instead of v ....

jeff.terrell13:10:25

Relatedly, I use the % motion a lot. (Scan forwards for next paren/bracket/brace and then jump to its match.)

jeff.terrell13:10:42

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
jeff.terrell13:10:15

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.

kirill.salykin13:10:15

Also cool thing you can combine d | c | v | r with ace jump

jeff.terrell13:10:39

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.

kirill.salykin13:10:26

Jumps to the end of the word

practicalli-johnny14:10:15

these are all excellent suggestions and helping make more use of Vim, feel free to keep sharing if you have them.

jeff.terrell14:10:08

OK. > and < (indent and dedent) operators, which are also useful with the aforementioned }/`{` motions.

jeff.terrell14:10:53

= (code-aware indenting) operator. Nice with the ap (a paragraph) text object.

practicalli-johnny14:10:47

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

jeff.terrell14:10:00

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

❀️ 4
jeff.terrell14:10:48

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
jeff.terrell14:10:07

zc and zo are useful to close and open folds, which can be a nice way of focusing on certain pieces of code.

practicalli-johnny15:10:26

Talking of code folds, anyone have preference over vim or origami style folds in Spacemacs. I think I am leaning towards vim style.

jeff.terrell15:10:29

I never really tried to use origami style, but vim-style is what I cut my teeth on and I'm comfortable with them.

jeremy19:10:38

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?

practicalli-johnny19:10:02

@jeremy642 you should use a hook.. let me dig out an example

practicalli-johnny19:10:47

(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)))

practicalli-johnny19:10:11

You can of course call a separate function rather than using the lambda

jeremy19:10:23

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

jeremy19:10:27

Let me give it a shot.

practicalli-johnny19:10:45

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.

practicalli-johnny19:10:14

I assume you are also putting the code inside the dotspacemacs/user-config function

jeremy19:10:49

That didn't work. I loaded a new repl and ret evaluates. Up and down just move the cursor.

practicalli-johnny19:10:54

Interesting, I used the same code a few weeks ago and it worked.

jeremy19:10:11

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.

jeremy20:10:53

Okay I got it.

jeremy20:10:03

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

jeremy20:10:11

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

jeremy20:10:38

Thanks for the help.

practicalli-johnny20:10:54

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

jeremy20:10:33

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.

jeremy20:10:49

Maybe too complicated? I don't know. haha

jeremy20:10:15

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