preservim / nerdcommenter

Vim plugin for intensely nerdy commenting powers
Creative Commons Zero v1.0 Universal
4.97k stars 447 forks source link

Ignore specific lines when comment/uncomment #501

Closed alligatorme closed 1 year ago

alligatorme commented 1 year ago

Is it possible to ignore specific lines beside blank line when commence/uncomment? Of course the specific line must startwith default delimiter, such as the following code, I use '//**'. Actually, I want to comment the following code once and then uncomment them after build using shortcut key 14\<leader>ci, but leave line 1 and 9 untouched.

 //**Ping Request********        
 root_declare!(0x00u8,PingReq,count=25);                                                         
 #[derive(BinWrite,BinRead,Debug)]                                                               
 #[brw(magic=0x00u8)]                                                                            
 pub struct PingReqLoad {                                                                        
     pub reqid: u64,                                                                             
 }                                                                                               

 //**Ping Response*********                  
 #[derive(BinWrite,BinRead,Debug)]                                                               
 #[brw(magic=0x01u8)]                                                                            
 pub struct PingRspLoad {                                                                        
     pub reqid: u64,                                                                             
 }   
alerque commented 1 year ago

Given the lines you want to ignore are already inline comments, no there isn't a way to do exactly what you want if you try to use inline comments to comment the lines again. I suggest using a block comment format to comment out the area with a single multi-line comment. Reversing that will then leave the inline comments intact.

alligatorme commented 1 year ago

Thanks. Using CommentMinimal as followed and set option let g:NERDRemoveAltComs=0 in .vimrc, the block comment part can be ignored in comment invert operation.

 /*Ping Request*/       
 root_declare!(0x00u8,PingReq,count=25);                                                         
 #[derive(BinWrite,BinRead,Debug)]                                                               
 #[brw(magic=0x00u8)]                                                                            
 pub struct PingReqLoad {                                                                        
     pub reqid: u64,                                                                             
 }                                                                                               

 /*Ping Response*/              
 #[derive(BinWrite,BinRead,Debug)]                                                               
 #[brw(magic=0x01u8)]                                                                            
 pub struct PingRspLoad {                                                                        
     pub reqid: u64,                                                                             
 }