redguardtoo / evil-nerd-commenter Goto Github PK
View Code? Open in Web Editor NEWComment/uncomment lines efficiently. Like Nerd Commenter in Vim
License: GNU General Public License v3.0
Comment/uncomment lines efficiently. Like Nerd Commenter in Vim
License: GNU General Public License v3.0
In paredit mode, when I have something like the following:
(function
(some-call arg arg arg)
(some-other-call arg))
and insert a ;
on the last line it automatically does this
(function
(some-call arg arg arg)
; (some-other-call arg)
)
to keep the parentheses balanced.
But when I mark the line with nerd-commenter and call evilnc-comment-or-uncomment-lines
:
(function
(some-call arg arg arg)
; (some-other-call arg))
When no text is marked, I would like M-;
to toggle commenting the current line. Can you help me modify ~/.emacs
to achieve this behavior?
I have enabled evil-mode and evil-leader is set to ,
. And I have put (evilnc-default-hotkeys)
in my configuration and ,ci
works well. But the evil usage does not work, for example, ,,,
does nothing.
Do I make something wrong?
With the default setup from
(evilnc-default-hotkeys)
pressing M-;
does nothing in the following situation (where |
is the cursor):
|
(setq some-var nil)
It would be convenient if it started a new comment.
It handles the inverse operation correctly:
;; |
(setq some-var nil)
followed by M-;
yields
|
(setq some-var nil)
i am using the emacs 24.3, after i updated evil-nerd-commenter today, this error happened:
"Invalid function: with-eval-after-load"
evilnc-comment-or-uncomment-lines: Symbol's value as variable is void: b
evil 和 evil-nerd-commenter 都是最新版
(evilnc-default-hotkeys)
doesn't work anymore, and it prevents a clean initialization on startup when placed in .emacs.
It gives me this error message:
eval-after-load: Symbol's value as variable is void: evilnc-comment-operator
When I try to mark, highlight to end of line, and evil nerd comment out this typedef line, Emacs spews a debugger, the buffer contents are replaced with just the typedef line, and undo does nothing.
Oddly, when I close the buffer and repeat the same mark, highlight to end of line, and evil nerd comment steps, it works the second time.
https://github.com/mcandre/qc/blob/4b220af8221cc3057549d927b4e3b59b48325543/qc.h#L6
as title. use font-face, should be general enough, support different major-mode
I found your answer to a question about joining comment lines and removing the comment delimiter. This is functionality I'm pretty sure I had in vim (via regular J
, not a separate bind), though I can't remember for sure; perhaps it was some plugin I was using.
In any case, it's very useful functionality that I was surprised to not find in emacs or in any packages that I could find. You seemed to imply that you did it in this package, but I could find no mention of joining functionality.
Or were you simply referring to the method of detecting whether one was in a comment? If so, would you consider adding comment joining functionality to this package? It'd be nice if we could still use J
and the comment-joining functionality would only kick-in if we were in a comment, otherwise it would delegate to the regular J
evil functionality, instead of having to have yet another separate bind (although perhaps some people would like that as an option).
;; Version: 1.5.12
Thanks.
Hi (my apologies if this is not the right place to ask questions - I can close and reopen in stack overflow if desired),
I'm a vimmer coming over to spacemacs. I used to use nerdcommenter, so i was happy to see this port in emacs, and auto-included in spacemacs.
In vim (let's use javascript as an example), let's pretend I used visual mode to highlight a couple lines. I could use <Leader>cc
to comment them with //
, or <Leader>cs
to do "sexy" comments (wishing for a better name...) where it would surround the highlighted lines with /** */
.
Is this possible with evil-nerd-commenter? I can't seem to find anything in the emacs commands to support it.
Thanks very much for any advice/replies.
Hello,
When I select a region using shift-v and comment it using evilnc-comment-or-uncomment-lines, it also comments the line underneath the region.
Doesn't happen with a region selected with v.
error message:
Symbol's function definition is void: org-edit-src-find-region-and-lang
I am using the latest version of emacs and the packages below:
Enabled minor modes: Anzu Auto-Complete Auto-Composition
Auto-Compression Auto-Encryption Column-Number Cua Desktop-Save Evil
Evil-Leader Evil-Local Evil-Matchit Fic File-Name-Shadow Font-Lock
Global-Anzu Global-Auto-Complete Global-Auto-Revert
Global-Evil-Matchit Global-Font-Lock Global-Linum
Global-Page-Break-Lines Global-Rinari Global-Surround Global-Undo-Tree
Goto-Address-Prog Helm-Match-Plugin Helm-Occur-Match-Plugin Hes
Ido-Everywhere Ido-Ubiquitous Line-Number Linum Mouse-Wheel
Page-Break-Lines Rainbow-Delimiters Recentf Shell-Dirtrack
Show-Smartparens Show-Smartparens-Global Smartparens
Smartparens-Global Surround Tooltip Transient-Mark Undo-Tree
Whitespace Winner Yas Yas-Global
(Information about these minor modes follows the major mode info.)
Emacs-Lisp mode defined in `lisp-mode.el':
Major mode for editing Lisp code to run in Emacs.
Hello @redguardtoo
Thanks for this great plugin :)
You mention in the README that you have tested it, but I don't see the test suite.
Was wondering where is it? (or do you do it by hand?)
Tested on Emacs 23.4, 24.3, 24.4, 24.5
useful for comment parameters in function definition.
I love using evil-nerd-commenter to toggle the commented/uncommented state of blocks of code! However, when I try to do this in matlab-mode or octave-mode, it just inserts a new blank comment.
How can we tweak these modes to toggle commenting better?
It does work when I comment some line, and it always adds dnl
to the begin of the line. However It fails to uncomment, neither #
nor dnl
of the commented line.
FYI, the minor modes that are activated is as belows:
Enabled minor modes: Auto-Composition Auto-Compression Auto-Encryption Auto-Fill
Autopair Autopair-Global Column-Number Desktop-Save Display-Time Evil Evil-Local
File-Name-Shadow Font-Lock Global-Auto-Complete Global-Auto-Revert
Global-Font-Lock Global-Linum Global-Pointback Global-Undo-Tree
Goto-Address-Prog Ido-Everywhere Ido-Ubiquitous Line-Number Linum Mouse-Wheel
Openwith Pointback Recentf Shell-Dirtrack Show-Paren Tooltip Transient-Mark
Undo-Tree Yas Yas-Global
Thanks,
Hongxu Chen
use emacs api to select region, then call web-mode-comment
after comment I may need uncomment and vice vesa because web-mode "smart" comment api.
Hi,
I received below error message after updating evil-nerd-commenter on melpa recently.
Warning (initialization): An error occurred while loading `/Users/dawu/.emacs.d/init.el':
Symbol's value as variable is void: evilnc-comment-operator
To ensure normal operation, you should investigate and remove the
cause of the error in your initialization file. Start Emacs with
the `--debug-init' option to view a complete error backtrace.
I think this is related to the compiled byte files under evil-nerd-commenter directory. i.e. evil-nerd-commenter-pkg.elc and evil-nerd-commenter.elc. After manually deleted those two, I don't get the error message anymore.
At first I thought this might be some problem on melpa side, but purcell believes it looks like an upstream issue melpa/melpa#2042.
I use evil-nerd-commenter
in emacs-prelude
, it worked fine before until I updated my packages via package manager on melpa recently. Anyway to address this problem?
Thanks,
I'm trying to use evil nerd commenter to toggle on comments for the last block of code in my .emacs
file. This triggers a debugger error.
Code:
https://github.com/mcandre/dotfiles/blob/master/.emacs#L589-L594
Error:
Debugger entered--Lisp error: (void-function org-edit-src-find-region-and-lang)
org-edit-src-find-region-and-lang()
evilnc--working-on-region(19001 19116 comment-or-uncomment-region)
evilnc--comment-or-uncomment-region(19001 19116)
(lambda (b e) (evilnc--fix-buggy-major-modes) (evilnc--comment-or-uncomment-region b e))(19001 19116)
evilnc--operation-on-lines-or-region((lambda (b e) (evilnc--fix-buggy-major-modes) (evilnc--comment-or-uncomment-region b e)) 1)
evilnc-comment-or-uncomment-lines(1)
call-interactively(evilnc-comment-or-uncomment-lines nil nil)
why autoload so many global keybinds and not provide way for configuration .
I use org-mode which had define C-c c for org-capture
. it fails when (require evil-nerd-commenter)
so I must modiy evil-nerd-commenter ,by now has no way to config it , can support it ?
;;;###autoload
(defun evilnc-default-hotkeys ()
"Set the hotkeys of evil-nerd-comment"
(interactive)
(global-set-key (kbd "M-;") 'evilnc-comment-or-uncomment-lines)
(global-set-key (kbd "C-c l") 'evilnc-quick-comment-or-uncomment-to-the-line)
(global-set-key (kbd "C-c c") 'evilnc-copy-and-comment-lines)
(global-set-key (kbd "C-c p") 'evilnc-comment-or-uncomment-paragraphs)
[Deleted]
Sorry, I had mistaken the functionality of evilnc-comment-or-uncomment-lines
.
May I suggest using backslash \
as default leader key in evilnc-hotkey-comment-operator
and evilnc-default-hotkeys
instead of comma?
I would really like to keep my evil mode the same with default vim key bindings as much as possible. I've also noticed that in vim, neither vim-matchit
nor nerdcommenter
would overwrite the normal ,
functionality by default. Maybe it's better not to use ,
as default leader key for their Emacs equivalence too?
Thanks for your time and patience to import such great modes into Emacs.
I would like evil-nerd-commenter to use double slashes (//
) instead of slash-stars (/* ... */
) to comment code in c-mode. How can I configure it this way?
Happy new year! :D
and focus is at the beginning of the next un-commented line
Hi, I'm using your package for quite a while now and I like it a lot.
Today I tried the invert-line-by-line option for the first time and it doesn't work as expected.
Example:
if I type "evilnc-comment-operator j" , 3 instead of 2 lines are commented.
It seems like the wrong starting point of the evil-operator range is chosen.
Thanks for your work.
It's frequently used for evaluating lisp expressions (http://www.gnu.org/software/emacs/manual/html_node/emacs/Lisp-Eval.html)
Hi,
Maybe you've encountered this issue before, but I looked everywhere and were not able to find any solution for this.
When I activate org-indent-mode
, and I try and comment out code snippet in a file (this is my config file), the whole org-subtree opens up to the parent node, and all its children open.
If I have this:
** Python configuration
#+begin_src emacs-lisp
(setq python-python-command "~/anaconda3/bin/ipython")
(setq py-shell-switch-buffers-on-execute-p t)
(setq py-switch-buffers-on-execute-p t)
(setq python-shell-virtualenv-path "~/anaconda3")
(when (executable-find "ipython")
(setq python-shell-interpreter "ipython"))
#+end_src
** Anaconda config...
and try to comment a command, I will end up with:
** Python configuration
#+begin_src emacs-lisp
(setq python-python-command "~/anaconda3/bin/ipython")
(setq py-shell-switch-buffers-on-execute-p t)
;; (setq py-switch-buffers-on-execute-p t)
(setq python-shell-virtualenv-path "~/anaconda3")
(when (executable-find "ipython")
(setq python-shell-interpreter "ipython"))
#+end_src
** Anaconda config
#+begin_src emacs-lisp
(add-hook 'python-mode-hook 'anaconda-mode)
(setq python-shell-virtualenv-path "~/anaconda3")
#+end_src
I tried going through my config file, but were not able to find anything related. If you need more information, let me know.
I'd better separate one screen cast to several one
hello. plugins like vim-commentary and tcomment use the gc
as an operator. so i can gcc
to toggle a line, gcG
to comment to the end of a file, or gcp
to comment a paragraph, etc.
i tried adding (setq evilnc-hotkey-comment-operator "gc")
to my .emacs
but it's not working as expected. a value of "g c"
doesn't work either.
am i configuring it wrong or is this not supported? thanks.
Hello!
I'm newish to Emacs, and just rebuilt my configuration using Cask. After installing evil-nerd-commenter
I get the following error:
Symbol's value as variable is void: evilnc-comment-operator
My configuration is something like this (for evil):
(require 'evil)
(require 'evil-leader)
(require 'evil-matchit)
(require 'evil-nerd-commenter)
(require 'key-chord)
(evil-mode t)
(evilnc-default-hotkeys)
Which is where the error is triggered. Any tips on how to work through this? I'm not very familiar with Emacs lisp at this point. Thank you for any help in advance!
These commands:
evilnc-comment-or-uncomment-to-the-line
evilnc-copy-to-line
would be more convenient if after executing, user get a prompt asking for a line number. The key bindings are the same, but this is more intuitive. The reason is, sometimes user can accidentally trigger the key bindings without a prefix argument, and without a prefix argument, the commands comment or copy from the first line to the current line. This is confusing for new people, and annoying when user forgets to supply a prefix argument.
The number of key strokes is the same:
C-u <number> <key binding for command>
<key binding for command> <number> RET
As you can see, it is more explicit and safer for user when they accidentally run the commands.
see https://pay.reddit.com/r/emacs/comments/1kcdq0/evilnerdcommenter_100_released/cbnvj0l
notes:
Looks like evil-nerd-commenter
is looking for web-mode-is-comment
, which doesn't exist. In web-mode
, you can hit M-;
which apparently calls comment-dwim
.
no point comment line instead, if you want to comment current line, no need to select anything.
I do sometimes need comment function parameters
investigation:
Hi,
Evilnc is nice! I would love if evilnc support kill and copy lines from the cursor up to a specified line, so we won't have to mark lines anymore.
No body like to press "953,cl to comment to the line 953", it's 6 key press, instead, they want to press to "3,cl" or better "3,ll", "33,ll" will be next 3.
as title
Hi,
the comment-operator opens all org-headlines if I use it in a babel code-block.
Thanks.
When something like this:
<%= form_for @changeset, @action, fn f -> %>
<%= if @changeset.action do %>
<div class="alert alert-danger">
<p>Oops, something went wrong! Please check the errors below:</p>
<ul>
<%= for {attr, message} <- f.errors do %>
<li><%= humanize(attr) %> <%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="form-group">
<%= submit "Submit", class: "btn btn-primary" %>
</div>
<% end %>
is commented, you get this:
<!-- <%= form_for @changeset, @action, fn f -> %> -->
<!-- <%= if @changeset.action do %> -->
<!-- <div class="alert alert-danger"> -->
<!-- <p>Oops, something went wrong! Please check the errors below:</p> -->
<!-- <ul> -->
<!-- <%= for {attr, message} <- f.errors do %> -->
<!-- <li><%= humanize(attr) %> <%= message %></li> -->
<!-- <% end %> -->
<!-- </ul> -->
<!-- </div> -->
<!-- <% end %> -->
<!-- <div class="form-group"> -->
<!-- <%= submit "Submit", class: "btn btn-primary" %> -->
<!-- </div> -->
<!-- <% end %> -->
However, it doesn't actually comment out the templating tags as they have to be turned to the <%# %>
form. One suggestion would be to keep the existing html style formatting as it helps the editor display things properly.
web-mode
.test
).evilnc-comment-or-uncomment-lines
.The result is <!-- test -->
.
evilnc-comment-or-uncomment-lines
again.The result is <!-- <!-- test --> -->
. Expected test
.
as title
Currently, when I try negative arguments, evilnc-comment-or-uncomment-lines does nothing. It should comments previous line according to the supplied argument.
Other similar functions should support negative argument as well.
that's an extra package to install when I can implement it by myself.
Hi
just discoverd evil-nerd-commenter and loving it.
there is one issue i found where it wont work inside org mode code blocks ie:
CODE HERE
any idea why? can this be fixed
kind regards
Z
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.