Follow

Hey / evil-mode veterans, is there a language agnostic keybind to quickly comment or uncomment lines of code?

I've been looking and haven't found it yet.

· · Web · 5 · 3 · 2

Update: Thanks for the help all! I ended up with tpope's vim-commentary, bound to `<Space>c`.

@freedcreative

vim-commentary standard usage doesn't work for you?

@elliptic Web search tells me that's a plugin. (I'm brand new to vim & evil-mode). I'll follow that up, thanks!

@freedcreative np and good luck -- pretty much everything for vim by tpope is worth considering while you're looking there.

@freedcreative I'd have to call this "language-unified" not "agnostic"

Also good luck detecting C pre-99 vs C99+ vs a project in C99+ but still mandates block comment style for single line comments

@riking @freedcreative afaik this requires a plugin; in neovim i use tcomment

@freedcreative By default, no.

There is Vim-Commentary (github.com/tpope/vim-commentar), a plugin for VIM, that does that, though.

(I bet Emacs has something like that too, but I don't know what it is.)

@freedcreative How would "language-agnostic" work in this case? Would the script match the comment characters to the current syntax, say for Python, Java, PHP etc. and comment a single line (in normal mode) or multiple lines of text (in visual/select mode)? The Commentary plugin for Vim seems to do something like that, though I haven't tried it, if you haven't found a solution.

@lj_writes I did end up going with tpope's commentary plugin, and yes how you described it is just how it works. I have the same keybind, <Space>c, for both normal and visual mode so it makes it pretty easy to do single or multi-line comments.

I see from your toots you've also recently taken the plunge into vim? How are you finding it?

@freedcreative sounds like a great solution! I may install it myself if I get more into coding, though so far I've been resisting installing any, telling myself my growing .vimrc file is virtuously frugal & not a drag on performance 😁

I like Vim a lot so far! It takes a great deal of pain out of editing, mentally and physically, and I feel like I can almost talk to the editor. Also great for easily scripting little recurring tasks--it's very intelligent software, I would even say an assistant.

@lj_writes That sounds like a much more sensible approach than my kid-in-a-candy-store behaviour at vimawesome.com/

I know what you mean about feeling like you can talk to the editor. I've been coding a pretty long while now so had to break some habits, making it a bit of a hard transition, and now I only wish I'd learned it right from the beginning.

@freedcreative probably because I've been watching/reading devs finger-wag at the excessive use of plugins before I knew how to delete in word 😂 youtu.be/XA2WjJbmmoM begriffs.com/posts/2019-07-19- there's some great stuff there I've been hearing about though, wow!

With Vim I'm like the grandmother pointing at the screen going, "I need to jump to that word, and oh, replace everything beween brackets" and my patient grandchild does it, as long as I speak their language which is the hard part.

@lj_writes @freedcreative I don't use any plugins ™ (For real) I am using Vim for two years and never need a plugin for nothing. If I need it someday i'll install it but meanwhile I'm happy as it is.

@sergiotarxz @freedcreative Nerdtree is considered essential by many and fugitive looks sweet, but if I start to creep toward an IDE setup with Vim I think I might want to give Evil mode SpaceEmacs/Doom Emacs a fair shake first, since Emacs seems to have a much better framework for that kind of expansion.

@lj_writes @freedcreative I don't like IDEs they are too complex and get broken easily. I prefer something simple which works well always, if I have to map common actions by myself I find it better than making my development tool unstable.

@lj_writes @sergiotarxz I think I might end up paring it back over time. To get me productive though, after a decade with Sublime / Atom / VSCode it's helpful to have as many similarities as possible.

@lj_writes @freedcreative But it is true than lisp is the righ tool over vimscript to develop serious extensions.

@sergiotarxz @freedcreative OTOH I have heard reports that Evil Mode is not a perfect Vim replacement for some because of small differences that trip them up, like if something is very important to their workflow and it's missing or different I can imagine it would be very annoying. As long as performance and stability are satisfying for the coder's needs there's nothing wrong with extending Vim, and if there is the occasional crash Vim has a pretty robust backup & recovery system.

@lj_writes @sergiotarxz I'm using both right now. Vim for coding and Emacs with evil as an org-mode machine.

I do feel a difference. I really notice even the tiniest lag when typing, and I notice typing in vim with a bunch of plugins is snappier than typing in completely vanilla Emacs. You have to be a real stickler for typing responsiveness to notice it, but it's there.

@freedcreative @lj_writes set timeoutlen=0 if you find lag in vim when doing O I didn't understand your toot well so there is a 50% of me saying something unrelated. :)

@sergiotarxz Oh I meant that vim is not laggy at all for me, even if I load it up with a heap of plugins.

Thanks for the tip though!

@freedcreative I don't understand many words in english, your -isms are equally valid as the US and UK ones I am happy to learn more words. 😃
Sign in to participate in the conversation
Merveilles

Merveilles is a community project aimed at the establishment of new ways of speaking, seeing and organizing information — A culture that seeks augmentation through the arts of engineering and design. A warm welcome to any like-minded people who feel these ideals resonate with them.