Why use editors like (Neo)Vim/Emacs?

Hi!

I am curious about what would be the specific reasons why people would favor Vim/Emacs instead of “more typical”(?) approaches (SC-IDE, regular VSCode, Atom, Sublime Text, etc).

Do you use it for live coding as well? Does it helps a lot or does it add an extra layer of work?

People that favor Vim/Emacs tend to reject software that are strongly focused on mouse/visuals interaction elements?

Which specific features of Vim/Emacs help your SC practice?

Do you generally set you whole system to be more keyboard centric than mouse centric?

Do you use Vim/Emacs in order to allow you to use the same editor for multiple languages (SC, Python, C++, Lua, Lilypond, etc)?

I have used both vim and emacs for SC at various times, now back to using IDE. When I used scvim I had been doing a job working on remote web servers via ssh/vim and had the vim key commands in my fingers so it felt easier / more seamless. When I used emacs I was into the scripting and the macros and the idea that you can live your entire digital life within the text editor. Since I returned to the IDE about 6 years ago I have noticed I spend a lot less time trying to fix problems with my text editor.

2 Likes

Neovim with SCNvim is just a fantastic environment for SC, a joy. You can write scripts that send semantically meaningful sections of code to sclang - or pipe bits of text to other programs… and sclang can insert or otherwise process text in your buffer via Lua as well. check out this thread for more SCNVim - A NeoVim frontend for SuperCollider

Vim provides marks, folding, registers, macros, proper search and replace and many other productivity enhancers - and with nvim you get tree-sitter and snippets and auto-aligning and telescope who knows what else… at the cost of lots of learning and configuration. I have spent many hours hacking my nvim setup, true, but then I simply could not build the kind of big project I’m currently working on in the IDE…

And of course you need to take the time to learn the vim way of moving and acting in the first place - its a steep learning curve but can be very fast and pleasant in the end.

2 Likes

Interesting. So the scripting language is basically Lua, just like emacs-lisp is for emacs? (I don’t know Lua, but I understand it’s a minimalist language) I’ve played around with evil mode in emacs (vim keybidings emacs mode), and started to get used to it (although I turned it off now… ). I would give NeoVim a try eventually, specially if there were a detailed guide and documentation not just how to install, but how to configure the features you mentioned.

1 Like

As far as emacs is concerned, there is nothing very special re supercollider coding. I like to use the concept of “project” or “workspace”, which is absent in scide; having everything accessible in that project. Opening other frames (windows) in any arrangement. And, in general, the code is much more organized. But I don’t think the editor makes that much of a difference.

I opened a random old project to show what I mean, see the treemacs window on the side. That’ s what I mean. Also, somehow, indentation works much better in emacs. Other things that you would like are snippets. LSP servers are available for other languages, not for sclang yet. All sorts of things not specific to supercollider are also available (even github copilot, which seems to be trendy now, but less useful than what people say)

Yes, you end up using the mouse a lot less. This also happens when you use a tiling window manager like XMonad (my case).

1 Like

The scel code is basically the same aince 10+ years or more, but in theory, emacs could offer a lot more things for supercollider coding.

See this sound editor mode: Scratching Samples with Emacs on Vimeo

and Emacs as a musical instrument - Joseph Wilk

Emacs 29 has support for treesitter, and Emacs 30 will improve its widgets, which (as I understood) will make it easy to work with GUI elements and html graphic browsing.

1 Like

Impressive! This would be possible only in Emacs and too difficult to do with VIM? Or is it only a “syntax” difference?

If I am understanding it correctly, one + for nvim is to allow a SC workflow which is more like a professional software engineering context, right? searching in different files, seeing the project as a whole thing, accurate track of your changes, etc. Does this imply that your SC/VIM projects are more like algorithmic compositions, with big and complex code, that you run at once but take a long time editing? Also, that you don’t make GUI or interactive elements?

Can you say more specifically or with examples which scvim features helped you doing that?

All he used was osc and ASCII. Everything in emacs is configurable, literally. He coded in emacs lisp, a very simple lisp dialect for emacs.

code: view-pane/lib/live-numbers.el at master · repl-electric/view-pane · GitHub

I think in vim you would need to write plugins in lua. I don’t know how to compare the two.

1 Like

Oh, just that vim runs in the terminal with no gui. Nothing specific to SC

2 Likes

I came across this video recently. Although it is Csound - and I don’t have any strong skill on it - I was trying to guess how emacs was used in this context.

As far as I can understand, emacs is being used here to allow a realtime interaction with the synthesis server, make faster indentation, evaluate small blocks of code, make bigger leaps with the cursor (between blocks or groups of code blocks) and enabling auto-completion.

Can you point out some other examples?

1 Like

This is more or less the default setting for interpreted languages like Sclang. It changes slightly between modes, but it is basically like this. You can choose the keyboard shortcuts (emacs also allows you to use vim shortcuts, for example). Many people find emacs default keybindings quite odd, because it was created years before the CUA bindings (Ctrl-C, Ctr-V etc), but you also have the option to use it if you prefer. Others find it challenging to grasp all Vim key sequences, but the basic ones are quite easy. You can try both.

Skipping blocks is just one of those shortcuts. Evaluate code blocks on both editors, too

If you want some visual effects while evaluating the code block, you can write your own function, for example:

 

(defun evaluate-code-block ()
  "Evaluate the code block at point and highlight it with a pulsing effect."
  (interactive)
  (let ((start (progn (backward-up-list) (point)))
        (end (progn (forward-sexp) (point))))
    (pulse-momentary-highlight-region start end)
    (sit-for 1) 
    (eval-region start end)))

(global-set-key (kbd "<S-return>") 'evaluate-code-block)

Even fiction writers, not coders, sometimes end up using emacs to work: https://www.youtube.com/watch?v=FtieBc3KptU

BTW, I didn’t know CSound evolved like this. Pretty cool!

1 Like

I never hear this discussed but… I have a terrible memory for keyboard shortcuts, I don’t have good recall for more than maybe 6-8 common ones at any given time. This makes editors like vim and emacs completely unusable for me. Conversely, the command palette in VSCode was a huge leap forward for me, as I can type some text fragment for a command that I want, and usually find it immediately.

This is not to knock these text editors - I’ve watch people who work well with them, and the workflows are very cool & inspiring! But I’m always surprised that they’re organized around what I imagine to be a pretty particular and narrow sort of capacity (e,g, remembering a large number of letter and key combinations). Curious if anyone else has this problem?

FWIW I’ve never been a very fluid terminal terminal user because I have the same problem with command line flags - I’ve gotten shit for this from hardcore dev people once in a while, but ofc it’s no faster to use command line git if you have to read the man page every time you run any command… :slight_smile:

6 Likes

I think vim keybindings are almost a programming language per se… I felt it was too much for me, beyond the basic ones.

I usually have the same problem, but emacs shows in the mini buffer what are the options, so you learn as you go. You can just type the command too.

The benefit in productivity only comes when muscle memory is acquired. I feel that very clearly using XMonad (a tiling window manager), for example. Dragging windows on the screen is very tedious.

1 Like

nvim has a lively plugin ecosystem - I use which-key and Telescope for menus and fuzzy finding - and these are all hackable and configurable via Lua.

I’d also point out for those who haven’t tried it that basic vim is quite few key commands. - single letters are used for movements, copy paste, and selection and they are composed in a common sense way. so j is down - 4j is down 4 lines v is select v4j is select four lines below. y is copy - y4j is copy next four lines.

its not for everyone but it is super fast if you take the trouble to learn

2 Likes

my recent project is kind of like building a DAW - building the work environment at the same time as with building the piece - and the “app” is the editor. A lot of it is just ergonomics - making it possible to build out the piece in a reasonable amount of time! A scriptable editor just seems like a necessity

2 Likes
1 Like

I used to use sclang-mode, and wanderlust for e-mail, and org-mode for calendar/todo.

Now, in Emacs, I use only org-mode (which is also a nice user-friendly front-end for LaTeX).

I would really like a colorizer for my live-coding dialect in SC, and SC-IDE is never going to support that… but the time it would take to get (back?) up to speed on Emacs-lisp is time I should be spending on Chinese vocabulary. So that ain’t gonna happen either.

hjh

1 Like

“Emacs!”

But seriously, I think a minor mode with font-lock would be the easiest way to do something like this, if you can deal with regexp. In a few lines I think it’s possible to do it.

I’d be curious to compare how it would be possible to do in vscode, maybe writing an extension in typescript? Seems a bit more involved.

1 Like

Some reasons we need LSP also running on vim and emacs, not just vscode:

2 Likes

Maybe you could try to integrate the existing LSP server Scott has written into one or more of those editors’ client systems?

2 Likes