Git Product home page Git Product logo

nerdcommenter's People

Contributors

abelmartin avatar alejandrogallo avatar alerque avatar aluriak avatar antonk52 avatar benjifisher avatar bryanv avatar chaoyuelee avatar chreekat avatar codemedian avatar dsirov avatar ervandew avatar houl avatar inkarkat avatar jiaobuzuji avatar johntyree avatar lanjiann avatar li-zyang avatar mdlerch avatar natesire avatar ponkio-o avatar ppwwyyxx avatar ratanrsur avatar richchurcher avatar saep avatar sbdchd avatar scrooloose avatar someone-stole-my-name avatar svermeulen avatar tomtomjhj avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

nerdcommenter's Issues

First steps

Hi,

I have just put in my .vim/plugin/ folder the NERD_commenter.vim file and added the line 'filetype plugin on' in my .vimrc file.

Then I open vim, write a line in a .php file, go to normal mode and press 'cc' but nothing happens. I expected that line became commented.

Any help?

Javi

NerdCommenter not working with pathogen (for me?)

Commenter doesn't work under pathogen.vim (for me ;) )

I was following Tammer Saleh's guide to pathogen and set it up just as he described and have many plugins working well (including NERDTree).

I thought that adding NerdCommenter would work just as easily, but I can't get it to work.

$ ls -R ~/.vim/bundle/nerdcommenter
Rakefile doc      plugin

/Users/sgharms/.vim/bundle/nerdcommenter/doc:
NERD_commenter.txt tags

/Users/sgharms/.vim/bundle/nerdcommenter/plugin:
NERD_commenter.vim

Looks good to me...and the .vimrc?

 grep plugin ~/.vimrc
filetype plugin on

When vim loads up and I search the :NER autocomplete, I never see any NerdCom...

I must be missing something here right, some subtlety?

<leader>?

Maybe this should link to Vim's documentation of a keyboard leader?

Thanks for the help,

Steven

2.2.2 Uses /* */ for every comment

I have NERD_commenter 2.2.2 installed into vim 7.2.315 and it only ever uses the /* */ commenting scheme. I'm trying to comment ruby files and it's not working for me. This is the first time I've tried to use NERD_commenter so I'm not sure if it's a new issue or not. It does the same with xml files too.

Remove trailing spaces after a comment symbol

I usually comment stuff with a space between the comment symbol and the actual comment. Like this:

# commented code

But using <leader>cu leaves the space in, resulting in badly indented lines in python. Is there a workaround for this?

Toggle minimal comment

This is not a bug report, but kind of a feature request:

It would be great if there was an option to toggle minimal comments. If there's a comment in the first line of the selection , the whole selection will be uncommented. If there isn't, put the whole selection into a minimal comment.

I tried to do this myself, but I'm fairly new to vimscript, and the toggle algorithm seems to work line-wise...would it be possible to add such an option?

Typo in Doc

In 'doc/NERD_commenter.txt', line 636 is /1/, where should be /2/ (Note the quote sign and the space):

/1/=> "2": Turns the 'comment 'menu on with -c as the shortcut.
/2/=> "2": Turns the 'comment' menu on with -c as the shortcut.

using different leader

Can I use a different leader with NERDCommenter?

I have the following in my .gvimrc:
let mapleader = ","
and it works fine with some other mappings I use, such as:
nnoremap :noh

But when it fails to change NERDCommenter and :map shows

n \ca NERDCommenterAltDelims
v \cA NERDCommenterAppend
n \cA NERDCommenterAppend
etc.

remove space after appending comment

Hi,

when using the append comment function, the function adds a space after the closing delimiter (talking about C here). This is not a big problem, but the code conventions where I work ban spaces at the end of a line. Can this be removed, or is there a reason?

greetings, Dirk

Different comment style for file regions

Would it be possible to have the comment style change depending on the cursor's position within a multi-language file? The specific case I'm interested in is Javascript and CSS embeded in a HTML document. Within the script tags i'd like to use // or // style, // within the style tags and for the HTML:

<html>
<style>
    html{
        /*background:green;*/
    }
</style>
<script>
    //var foo = "bar";
</script>
<!--<body></body>-->
</html>

I had a look around and this doesn't seem to be possible in a 'nice' way (i.e. there isn't a 'current_region_code_type' variable set). I've never done any vim programming though, is this correct?

[FEATURE] Add option for anchoring left comments to leftmost word

Currently, there is no way (I don't think) to comment blocks with a fixed location for the leading comment:

myfunc() {
    foo();
}

to:

# myfunc() {
#     foo();
# }

It would be nice if NERD_commenter could provide an option to anchor left comments to the leftmost position for the selection. That way I can stop using <C-v>I# <Esc> to comment in this style.

comment menus don't show the correct mapleader

In the menu that is generated, the tooltip for each command always shows the mapleader as "". It looks like line 2711 needs to be changed to the following to work properly.

let leader = exists('g:mapleader') ? g:mapleader : '\'

Is there a way of specifying the key starting the mappings

Hi I am still using an older version of this script, and in that version all the mappings start with a comma ",".
I see that in the latest version the letter starting the mappings is specified by leader.
In my case leader is "" and I would like to keep it that way, but I am used to the mappings provided by this plugin so I would like to know if there is a simple way of customizing it (without having to define all the mappings in my vimrc)

Thanks!

Error message while toggling comments

This is the mapping:

\\ <Plug>NERDCommenterToggle

This is the code:

# default-character-set=utf8
# default-storage-engine=INNODB
# innodb_file_per_table
# # innodb_buffer_pool_size=1G
# innodb_log_file_size=128M
# innodb_log_buffer_size=8M
# innodb_flush_log_at_trx_commit=2
# innodb_thread_concurrency=16
# innodb_flush_method=O_DIRECT
# innodb_file_per_table

When I select visually the above lines and use \, I get the following error:

Error detected while processing function NERDComment:
line   57:
E685: Internal error: get_tv_string_buf()
E116: Invalid arguments for function s:Left({'alt': 1}), theLine)
E116: Invalid arguments for function s:IsCommentedFromStartOfLine(s:Left({'alt': 1}), theLine)
E15: Invalid expression: s:IsInSexyComment(firstLine) || s:IsCommentedFromStartOfLine(s:Left(), theLine) || s:IsCommentedFromStartOfLi
ne(s:Left({'alt': 1}), theLine)

problem with vim 7.0.237

Error detected while processing function NERDComment..<SNR>11_CommentLinesSexy..
<SNR>11_LeftMostIndx:
line   13:
E685: Internal error: get_tv_string_buf()
E116: Invalid arguments for function s:Left({'alt': 1}), s:Right({'alt': 1}), th
eLine))
E116: Invalid arguments for function s:IsCommented(s:Left({'alt': 1}), s:Right({
'alt': 1}), theLine))
E15: Invalid expression: a:countCommentedLines || (!s:IsCommented(s:Left(), s:Ri
ght(), theLine) && !s:IsCommented(s:Left({'alt': 1}), s:Right({'alt': 1}), theLi
ne))

Sexy Haskell comments no longer sexy

I've been away from Haskell for more than half a year (I think) so I don't know when this change might have happened.

The old code I revisited has comments that look like the following, which was generated by NERDComSexyComment:

{-
 - Some sample documentation.
 - Nothing special.
 -}

Uncommenting that with either NERDComUncommentLine or NERDComToggleComment obviously left just the two lines of text (maybe with that extra space before the "S" and the "N", don't remember that).

NERDComSexyComment today generates this on the same text:

{- Some sample documentation. -}
{- Nothing special. -}

It's not the same anymore, and the top one can't be uncommented properly anymore either. If one tries to, the leading dashes on the second and third line are kept.

s:HasCStyleComments expression fails in Vim 7.0

This was encountered on Vim 7.0.237, the stock version for Red Hat and CentOS 5. When toggling a comment the expression in s:HasCStyleComments yields the following error:

E685: Internal error: get_tv_string_buf()
E116: Invalid arguments for function s:Left({'alt': 1}) == '/*' && s:Right({'alt': 1}) == '*/')
E15: Invalid expression: (s:Left() == '/*' && s:Right() == '*/') || (s:Left({'alt': 1}) == '/*' && s:Right({'alt': 1}) == '*/')

Since I lack vimscript-fu I don't know if this is easily fixed, but it sure would help for those of us stuck on older Vim versions. The error does not occur on newer Vim versions (the next oldest I have is 7.2.411 which works fine).

Smarter Support for Templating Comments

I'm going to use ERB for this example even though this would probably be the same case for Python, PHP, ASP, etc.

Let's say I have a line like so:

<div>
    <%= link_to "Some Link, some_url_helper %> Followed By Some Text
</div>

If I select all 3 lines, NERDCommenter does this:

<%# <div> %>
    <%# <%= link_to "Some Link, some_url_helper %> Followed By Some Text %>
<%# </div> %>

Which works for lines 1 and 3 but does not work for line 2. Because of the inner %>, the comment stops BEFORE the "Followed" text and the last %> is output as regular text.

What I would like to see is this:

<%# <div> %>
    <%# <%= link_to "Some Link, some_url_helper --> Followed By Some Text %>
<%# </div> %>

And then when swapped back, NC knows to replace the --> with %> again. That being said, if it's easier, ERB also has a multiline-comment syntax which would work as well.

<%
=begin
<div>
    <%= link_to "Some Link, some_url_helper %> Followed By Some Text
</div>
=end %>

This would accomplish the same thing and for a visual selection, seems to be the better option.

I would implement this myself but I have ZERO Vimscript skills. :)

Thanks for the awesome plugin!

call to s:delimiterMap

How I can call to s:delimiterMap from other functions?
// for not re write a similar dic with comments chars

would be nice if there was a space

highlight text and type \cs does what I want, only it would be nice if there was a space after the *

 /*
  *comment
  *comment
  */

becomes

 /*
  * comment
  * comment
  */

Also, I see a leading /** a lot, don't know what thats about, but it looks like common practice

 /**
  * comment
  * comment
  */

SQL comments for MySQL

MySQL require a space after double dash in order to create line comments.

This is not a valid comment:

SELECT `coupons`.* FROM `coupons`  
WHERE `coupons`.coupon_list_id = 55 AND coupons.expires_at IS NULL      
AND `coupons`.coupon_list_id = 55   
--ORDER BY expires_at 
LIMIT 1;

And here is valid one:

SELECT `coupons`.* FROM `coupons`  
WHERE `coupons`.coupon_list_id = 55 AND coupons.expires_at IS NULL      
AND `coupons`.coupon_list_id = 55   
-- ORDER BY expires_at 
LIMIT 1;

Can you please modify SQL commenter to always include that space?

Add support for GSP

Could you please add gsp support (it is the same as jsp: <%-- comment --%>)?

SQL comment not working

In your comments the SQL one should be as follows:

\ 'sql': { 'left': '-- ' },
\ 'sqlforms': { 'left': '-- ' },
\ 'sqlj': { 'left': '-- ' },

and not as it is

\ 'sql': { 'left': '--' },
\ 'sqlforms': { 'left': '--' },
\ 'sqlj': { 'left': '--' },

The difference is that the correct comments are tree chars . There might be someway to configure SQL to understand the two char comment. But it easier to add the space xD

Multi-filetype support

My GSP files are set to filetype=gsp.html

Is there anyway of telling NERDCommenter to use the rule for 'gsp' instead of 'html'. It doesn't matter if the filetype is set to 'gsp.html' or 'html.gsp'. The 'html' comment type will have precedence. If I set the filetype to 'gsp' only, the comment type for 'GSP' works as expected. It would be great to be able to decide which one to use from NERDCommenter

Enable aligning toggled comments

Add option to left-align the comment symbol rather than put it just before the first character. For example...

allow this:

//    public int getId() {
//        return id;
//    }

instead of this:

   // public int getId() {
       // return id;
   // }

I believe the first option above is more readable

Possible implementation:

function s:CommentLinesToggle(forceNested, firstLine, lastLine)
...
            if g:NERDAlignCommentToggle
                let theLine = s:AddLeftDelimAligned(s:Left({'space': 1}), theLine, 0)
            else
                let theLine = s:AddLeftDelim(s:Left({'space': 1}), theLine)
            endif

can't install

I folllowed the git instructions, but the mapping doesn't exist.

Ignore "tags"

Please add "tags" in .gitignore.
E.g.: with git > 1.7 and nerdcommenter loaded as bundle (pathogen) with a git clone your plugin is always marked as dirty.

Thanks,
Marco

[C/C++] Add the ability to comment multiple independent groups on the same line

First of all, thank you for this great plugin, but I have a wish. It would be nice to be able to comment multiple groups on the same line. Suppose that we have this line in C++:

if (m && row < rows /*&& row >= 0*/ && column < columns |&& column >= 0|) {

where "|" are the delimiters of the visual selected block, would be nice to have a mapping that will be able to make the result:

if (m && row < rows /*&& row >= 0*/ && column < columns /*&& column >= 0*/) {

I have tried all the mappings, but I could not get this result.
The mapping cn makes this result:

    if (m && row < rows /*&& row >= 0<] && column < columns [>&& column >= 0*/) {

Thank you!

Allow joining commented lines

If I have the following code:

// This is a multiline
// comment but it's a bit misaligned

I'd like to VjJ to select & join both lines and have the second set of // removed.

[error, please cancel] LaTeX support?

I'm trying to get NERDCommenter to work with LaTeX files (.tex), but even if :set ft? shows me filetype=tex, NERDCommenter does not work. Enquiring over, I see that the .tex filetype is not hardcoded among the others in plugin/NERD_commenter.vim (we have ConTeX, LyTeX, TeXinfo).

Now, I can add this by myself, but probably introducing LaTeX support could be a good idea.

Comment suffix

I find useful to mark part of the comments with 'XXX''.
This is useful when commenting some lines for a quick test, or as a short time
todo reminder, as it is easy to find those lines through a search in the
project files.

Is it possible to set up an option string that is inserted after the start of
a comment for all languages? Something like 'g:NERDComSuffix' in the example
below?

.vimrc:
nmap \cx :exe 'let g:NERDComSuffix = "XXX" | normal \c '|let g:NERDComSuffix =""
nmap c NERDCommenterToggle
xmap c NERDCommenterToggle

c code:
for (int i = 0; i < count; i++)
{
// XXX tempDisabled(); -> result of 'cx'
// if () -> result of 'c '
{
dfa
}
}

Inserting a comment in Insert mode

Hi,

I downloaded the dev version of this script (to get Less support).

Now, my old mapping for inserting comments in insert mode doesn't work anymore.
It was: imap : NERDCommenterInInsert

So firstly, I understand that the name has changed to "NERDCommenterInsert" without the "in" part. Changing this didn't help.

I also looked at the docs, and it says there is a variable you can define to get the mapping. I couldn't get that to work, not with the mapping or my own custom one.

I tried several other tricks, nothing worked.

Eventually, I realized I could do this: imap :call NERDComment("n", "insert").

Now it works, but obviously it's not great that nothing else worked.

Thanks!

Feature Request: NERDComAppendToggle

I often find myself in the situation where I have comments appended to a line and want to move them to a separate line (one line up) or vice versa.

So a function to toggle that would be nice.

Commenting .ss (lisp scheme) properly

Not sure where to put this question. I'm trying to get nerdcommenter to properly comment a scheme file.
When i hit ,c it comments with the C-style /* */ it should be a leading ; for single-line comments.
I assume this C-style is the default for unknown filetypes?

I've tried modifying the script myself and adding something like:

elseif a:filetype ==? "ss"
     call s:MapDelimiters(';', '')

This seems to work for other languages. Have I missed something? Is "ss" interpreted in some weird way? I know that I'm editing the right file, because if I change the comment-style of e.g. C-files, the changes appear appropriately in C comments.

Ideally I suppose it should be like this:

elseif a:filetype ==? "lisp <OR> ss"
      call s:MapDelimitersWithAlternative(';','', '#|', '|#')

Can I get some directions? Feel free to delete this issue, as it's probably just me being retarded, and not really a bug or feature request :-)

Anyways, I'm currently on:
vim 7.0
NERD_commenter version 2.2.2

NERD_<filetype>_alt_style being ignored?

I'm trying to set up a few languages to use alternate comment styles by default. According to the documentation, I just need to add let NERD_<filetype>_alt_style=1 to my .vimrc file. If it matters, I'm using the code directly from this git repo and everything else works just fine.

I've tried adding the following which have seemingly no effect at all:

let NERD_haskell_alt_style=1
let NERD_c_alt_style=1

Using leader-ca works as expected.

NERD_<filetype>_alt_style ignored

It appears that g:NERD_c_alt_style, for example, gets ignored. When I set this in .vimrc and then comment something, I still get old style /* */ comments. If I do ,ca it will switch as expected.

Am I doing something wrong here?

Also :echo g:NERD_c_alt_style shows 1.

bug: remove comments pascal

Se tenho um bloco de código.

linha 1
linha 2

Use the command ",cs" visual block mode.

(* linha 1
 * linha 2
 *)

When I use "c " does not remove it, instead creating another comment.

(* linha 1
 {* linha 2}
 *)

Sorry for the poorly written text, I do not know English.

Comments broken on Ruby files

Maybe file type detection is wrong, but commenting single lines as well as sexy comments for Ruby files don't work properly. It comments as it was a C file (/* */ and //) instead of a Ruby comment (#)

Steps to reproduce:
1 - Create or edit a Ruby file with one or more lines of code
2 - Try to comment one or more lines.

Ruby comments works fine on version 2.2.1 from vim.org (http://www.vim.org/scripts/script.php?script_id=1218)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.