Vim - Nerd commenter . First line commented out differently - macos

When using nerd commenter in visual mode, the first line is commented differently.
Initial code
const IMG_SIZE_SMALL = '32x32';
const IMG_SIZE_MEDIUM = '64x64';
const IMG_SIZE_LARGE = '192x192';
After doing ,cc in visual mode selecting these lines.
/* const IMG_SIZE_SMALL = '32x32';*/
//const IMG_SIZE_MEDIUM = '64x64';
//const IMG_SIZE_LARGE = '192x192';
What should I do so that the first line is also commented out using // ?

You didn't mention what filetype the file has. I tried creating a small test.c file with only the lines provided in your question and used ,cc to comment out the lines. I tried two different filetype settings. With filetype=c, the lines were all commented out with /* --- */ style comments and with filetype=cpp, the lines were all commented out with // style comments. Have you made sure you are using the latest version of NERD_commenter (2.2.2)?
Ok, now I created a small test file with these lines and some testing lines above and below them. NERD commenter comments them all with the same //-style comments. You don't happen to be selecting lines in character-wise mode? That is pressing v instead of shift-v to select the lines? When i tried that i was able to get different comment styles for some lines.

Related

MigraDoc - extra and unwanted NewLines

I have a code, where I create a paragraph with 4 lines, 3 of them use tabs to separate row labels and parameter. Astonishingly, a code that worked flawlessly in another form is giving me big headache in current form, even though it is practically 100% identical. Two extra lines appear between line label and a parameter.
Dim ParPara As New Paragraph ' create new paragraph
Dim formtext As New FormattedText
formtext.Bold = True
formtext.AddText("ABC 12345")
Dim formtext2 As New FormattedText
formtext2.Bold = True
formtext2.AddText("163658468435831484")
Dim formtext3 As New FormattedText
formtext3.Bold = True
formtext3.AddText("PARAMETER 1")
ParPara.Add(formtext4)
ParPara.AddLineBreak() ' intentional line break at the end of line
ParPara.AddText("Row Header 1:")
ParPara.AddTab()
ParPara.Add(formtext)
ParPara.AddLineBreak() ' intentional line break at the end of line
ParPara.AddText("Row Header 2:")
ParPara.AddTab()
ParPara.Add(formtext2)
ParPara.AddLineBreak() ' intentional line break at the end of line
ParPara.AddText("Row Header 3:")
ParPara.AddTab()
ParPara.Add(formtext3)
...
TableRowHead0F.Cells(1).Add(ParPara)
I even compared in-memmory content of the paragraph and it's 100% identical in both forms, one working flawlessly and another one inserting extra NewLine breaks:
The in-memmory structure is correct:
The migradoc styles are set identically in both forms (working and failing) too.
Anyone has any ideas why this is happenning?
EDIT: As suggested, I compared MDDDLs and I see no differences:
I don't know, if there can be some context (cell style?) affecting this, but it's really odd. Not the first time I see something like this with MigraDoc...
EDIT 2:
The problems was in switching an order of lines of definition of one style, I had 2nd line of this code at the end:
Dim sStyle As Style = PruvDoc.Styles(StyleNames.Normal)
sStyle = PruvDoc.Styles.AddStyle("Quest", "Normal")
sStyle.ParagraphFormat.TabStops.Clear()
sStyle.ParagraphFormat.TabStops.AddTabStop("9cm", TabAlignment.Left, TabLeader.Dots)
...and that meant that tab stops were applied to the "Normal" style, instead "Quest". Against expectation, it was defined well after the part, where the problems ocured(good to know).
A useful approach to investigate such problems: You can create MDDDL files for the version that works and for the version that does not work and then compare the MDDDL files.
See here:
http://pdfsharp.net/wiki/MigraDocDDL.ashx
MDDDL files are somewhat readable and can be used to check what you actually add to your document - even if you only have a version that does not work as expected.

How do I comment in Power Query M?

Is there a way to comment M code / comment out lines or blocks of code?
M supports two different types of comments:
Single line comments can be started with //
You can comment out multiple lines or comment out text in the middle of a line using /* */ (e.g. = 1 + /* some comment */ 2)
Comments might seem to disappear in the formula bar if they are at the end of the line, but they are still there. You can verify this by looking at your code in the Advanced Editor.

Overlapping mutli-line comments

In C#, is there a reason why multi-line /* */ comments can't overlap? This also applies to HTML (and I'm sure lots of other languages) too.
e.g.
/*
int a = SomeFunction();
/* int i = 0; */
int b = SomeFunction();
*/
won't compile.
When writing code I often want to quickly check the logic, and isolate certain parts by removing a section using multi-line comments, but then have to go through the code block replacing all multi-line comments with single line ones //.
I don't like using single line comments to comment-out code blocks (even though Visual Studio provides shortcuts to do this) as these then affect text comments when it comes to removing all comments in the block using the shortcut.
Is there a reason why the multi-line comment cannot mean: 'ignore everything between here'?
I'm afraid this is the way how it's designed.
I think you should use single line comments as much as possible. It's also much clearer when you are viewing the history of a file in source control. If you commented an entire method with /* */ then only two lines will appear changed, otherwise the entire method will have been changed (// added).

Modifying Xcode syntax highlighting to gray-out NSAssert lines

I want to modify Xcode syntax highlighting. Namely, I do a lot of 'NSAsserts', which I find visually distracting, and so I would like lines starting with 'NSAssert' to be a light gray. This way, I can focus upon my code logic instead of having to cognitively filter-out the NSAssert lines.
I use a lot of these too, and I liked your idea enough to work out the answer. Well, sort of: I have not worked out how to treat NSAsserts as a new item but I have worked out how to make them appear as comments in the syntax highlighter.
Create the directory ~/Library/Application Support/Developer/Shared/Xcode/Specifications
Copy BaseSupport.xclangspec from /Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources to that directory
Apply this patch to the new copy:
--- /Developer/Library/PrivateFrameworks/XcodeEdit.framework/Versions/A/Resources/BaseSupport.xclangspec 2010-10-05 00:27:45.000000000 +0100
+++ /Users/philwill/Library/Application Support/Developer/Shared/Xcode/Specifications/BaseSupport.xclangspec 2010-12-14 11:36:51.000000000 +0000
## -100,9 +100,8 ##
Identifier = "xcode.lang.comment.singleline";
BasedOn = "xcode.lang.comment"; // for text macros
Syntax = {
- Start = "//";
- EscapeChar = "\\";
- Until = "\n";
+ StartChars = "/N";
+ Match=("//.*$","NSC?Assert[12345]?[[:space:]]*\\([^;]*\\)[[:space:]]*;");
IncludeRules = ( "xcode.lang.url", "xcode.lang.url.mail", "xcode.lang.comment.mark" );
Type = "xcode.syntax.comment";
};
Caveats:
This will mess up any //-comments
which contain escaped newline
characters. Don't do that.
This will theoretically slow down
syntax highlighting a little. I
haven't noticed any difference.
This will affect all languages you use in Xcode which normally allow //-comments.
This is the best that Xcode currently permits you to do.

Reformatting text (or, better, LaTeX) in 80 colums in SciTE

I recently dived into LaTeX, starting with the help of a WYSIWYM editor like Lix. Now I'm staring writing tex files in Sci-TE, It already has syntax higlighting and I adapted the tex.properties file to work in Windows showing a preview on Go [F5]
One pretty thing Lyx does, and it's hard to acheive with a common text editor, is to format text in 80 columns: I can write a paragraph and hit Return each time I reach near the edge column but if, after the first draft, I want to add or cut some words here and there I end up breaking the layout and having to rearrange newlines.
It would be useful to have a tool in Sci-TE so I can select a paragraph of text I added or deleted some words in and have it rearranged in 80 columns. Probably not something working on the whole document since it could probably break some intended anticipated line break.
Probably I could easily write a Python plugin for geany, I saw vim has something similar, but I'd like to know if its' possible in Sci-TE too.
I was a bit disappointed when I found no answer as I was searching for same. No helpers by Google either, so I searched for Lua examples and syntax in a hope to craft it myself. I don't know Lua so this can perhaps be made differently or efficiently but its better then nothing I hope - here is Lua function which needs to be put in SciTE start-up Lua script:
function wrap_text()
local border = 80
local t = {}
local pos = editor.SelectionStart
local sel = editor:GetSelText()
if #sel == 0 then return end
local para = {}
local function helper(line) table.insert(para, line) return "" end
helper((sel:gsub("(.-)\r?\n", helper)))
for k, v in pairs(para) do
line = ""
for token in string.gmatch(v, "[^%s]+") do
if string.len(token .. line) >= border then
t[#t + 1] = line
line = token .. " "
else
line = line .. token .. " "
end
end
t[#t + 1] = line:gsub("%s$", "")
end
editor:ReplaceSel(table.concat(t, "\n"))
editor:GotoPos(pos)
end
Usage is like any other function from start-up script, but for completness I'll paste my tool definition from SciTE properties file:
command.name.8.*=Wrap Text
command.mode.8.*=subsystem:lua,savebefore:no,groupundo
command.8.*=wrap_text
command.replace.selection.8.*=2
It does respect paragraphs, so it can be used on broader selection, not just one paragraph.
This is one way to do it in scite: first, add this to your .SciTEUser.properties (Options/Open User Options file):
# Column guide, indicates long lines (https://wiki.archlinux.org/index.php/SciTE)
# this is what they call "margin line" in gedit (at right),
# in scite, "margin" is the area on left for line numbers
edge.mode=1
edge.column=80
... and save, so you can see a line at 80 characters.
Then scale the scite window, so the text you see is wrapped at the line.
Finally, select the long line text which is to be broken into lines, and do Edit / Paragraph / Split (for me the shortcut Ctrl-K also works for that).
Unfortunately, there seems to be no "break-lines-as-you-type" facility in scite, like the "Line Breaking" facility in geany. not anymore, now there's a plugin - see this answer
Well, I was rather disappointed that there seems to be no "break-lines-as-you-type" facility in scite; and I finally managed to code a small Lua plugin/add-on/extension for that, and released it here:
lua-users wiki: Scite Line Break
Installation and usage instructions are in the script itself. Here is how SciTE may look when the extension properly installed, and toggle activated after startup:
Note that it's pretty much the same functionality as in geany - it inserts linebreaks upon typing text - but not on pressing backspace, nor upon copy/pasting.
the same but more easy, I think...
put this in the user properties:
command.name.0.*=swrap
command.0.*=fold -s $(FileNameExt) > /tmp/scite_temp ; cat /tmp/scite_temp >$(FileNameExt)
command.is.filter.0.*=1
Ciao
Pietro

Resources