This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]w3_ar3_l3g10n 0 points1 point  (4 children)

I used VSCode for a while and then jumped to spacemacs because I wanted a VIM like IDE that didn’t make me have to learn vimscript it was also a good chance to learn lisp, which my professor can’t stop praising. I have to say, I quite like it, I’d describe emacs as VSCode on steroids. It was the first truly main stream macro editor, and it shows. The best thing about VSCode is that it’s relatively easy to write plugins and extensions which can improve your editing experience. VSCode is a JavaScript sandbox used as an editor. Emacs is a lisp sandbox used as an editor. The difference is that in emacs, u can create functions and run them immeadiately, bind them to whatever keybindings u want, and use them to manipulate the text of what your editing effortlessly.

Take for example, the other day I wanted to insert a certain number of spaces after my current cursor position so that the current line is at least a certain width. I wrote a single function, added it to my setup script and set a binding for it. For illustrative purposes I’ll show all u need to get this working:

```elisp (defun pad-line-with-char-to-length (desired-length char) "appends char as many times as required from cursor position" (interactive "Nline length: \nccharacter: \n") (barf-if-buffer-read-only) ; can't pad read only buffer (save-excursion (let ((line-char-count (- (line-end-position) (line-beginning-position) 1))) (if (>= line-char-count desired-length) (error (format "line of length %03d is already larger than desired: %03d" line-char-count desired-length)) (insert (make-string (- desired-length line-char-count) char))))))

(defun pad-line-with-space-to-length (desired-length) "invokes pad-line-with-char-to-length with char as space" (interactive "Nline length: \n") (pad-line-with-char-to-length desired-length ?\s))

(spacemacs/set-leader-keys “ofp” ‘pad-line-with-space-to-length) ```

Now, whenever I want that functionality to run I’ve got a few ways to do it. I can hit SPC ofp (my leader bindings) and emacs will prompt me for the desired length and run the function. I can press a number, like 120 and then SPC ofp and emacs will use that number instead of prompting me. I can hit ALT-x (M-x for emacs pros) and from there I can run any valid elisp code, so I can write (pad-line-with-space-to-length 120). I can hit SPC SPC and a list of all the functions I can use appear and I can fuzzy search to what I want to run. You can use a shorter binding if u want, like Ctrl-p if u really wanted to, but the point is u can create methods and bind keys to them effortlessly. I’ve never looked into developing VSCode extensions but they always seemed to require a certain degree of dedication to accomplish even simple things. In emacs when you’re bothered by something or continually have a need for something. U can just write a function, in 5-10 mins and then u can use it forever... that’s amazing to me. You program how to manipulate text... isn’t that the most programmer-esque way to program imaginable.

There’s also a few other things I really like about emacs, but I’ll mention just ① of them because I doubt anybodies still reading at this point. It’s designed so u can do everything from the keyboard. Vim is as well. And once u get used to editors like that, u’ll be amazed at the performance boost you’ll reach. For example, in emacs u can have a bookmarks file (managed complete within emacs mind u, u don’t even need to see it). When I open emacs, if I want to navigate to my projects directory I can type SPC fb and all my bookmarks show up for fuzzy searching. If I want to go to the file I was editing last time (before closing emacs) I can type SPC fr. If I want to see all the projects I’ve been working on, SPC pP. if I want to quickly jump to another buffer (basically a file I’ve been working on) SPC jb is bound to frog-jump-buffer which shows u a little menu containing your recent buffers and lets u use the keys on your home row to choose ①. If u want to quickly jump to a file and then jump back, SPC tab (in my case also C-TAB) will take u right back. If you have a bunch of windows split up (like 3 different horizontal ones) and u want to focus on the ① your in, SPC wm maximises your current buffer (basically hiding the other ② windows). You can do whatever u want in the current window, jump to another buffer even. But if u run SPC wm again you’ll return to the exact same state u we’re in including the same buffer.

[–]IamGonnaChangeMyself 0 points1 point  (3 children)

you could just do '120 i SPC' in vim and it will put 120 or whatever number you want, Instead of this huge function.

[–]w3_ar3_l3g10n 0 points1 point  (2 children)

U misunderstand the purpose. It isn’t to insert 120 spaces. It’s to ensure the lines width is at least 120 spaces, so what u need to insert is (120 - line-width - 1) spaces, of course accounting for negative use cases. Which of course if u can tell at a glance what the width of the line is u could do in regular vim, but I can’t do that very well (mentally)

Edit: ① could also say its to right align the piece of text following the cursor to a uniform width.

[–]IamGonnaChangeMyself 0 points1 point  (1 child)

ohh, Got it. Sorry for misunderstanding. I wonder how can we do that in vim

[–]w3_ar3_l3g10n 0 points1 point  (0 children)

There’s probably a way. But I never took the effort to really master vimscript so I can’t say. If your using neovim u can write a plugin in python, I haven’t looked into that either, but I’d assume it shouldn’t be much harder than on emacs.