Line Notes for VSCode - visual-studio-code

Is there any way by which I can add a useful message to a line in VS Code Editor which is not written in code but is like a note (Similar to like comments on a line in a Pull Request in Git) which can be deleted later on.

Here are the two extensions that I came across, hope this helps:
1). Line Note: https://marketplace.visualstudio.com/items?itemName=tkrkt.linenote
2). Code Annotation: https://marketplace.visualstudio.com/items?itemName=tkcandrade.code-annotation
I preferred Code Annotation for it's seemingly active org admin and the team of contributors and for marking notes as DONE or PENDING feature.

The "Line note" extension https://marketplace.visualstudio.com/items?itemName=tkrkt.linenote is probably what you are looking for…

Many languages allow you to append a comment to the end of a line. In python for example, you could have the following:
import numpy as np
a = 13.6 # a is the density of material
anser = a * b # where b is the volume in meters/cubic centimeters
...
Do not know what your language is but maybe this could work.

Comments can be added to code based on what language you are using. They are not specfic to the editor for the most part.
For example, in C++ you can comment by putting double slashes before the line such as // Random Comment.
Look up the commenting syntax for whatever code language you are using.

Related

Why doesn't GitHub like the % character?

I have a GitHub repo with multiple C source files. (I won't share a link unless absolutely necessary so that I can't be accused of advertising.) Every instance of the % character in the C files is highlighted red:
Am I missing something about % in C, is this a bug, or is it intentional?
GitHub uses linguist for detecting languages, and some highlighting issues can be found there (even if it does not directly concern the language detection module)
See issue 2839 which does mention
We use open source TextMate-style language grammars for syntax highlighting, which are available here:
https://github.com/github/linguist/blob/master/grammars.yml
Linguist pulls in grammar updates with each new release, which usually happens every couple of weeks.
For C, is is textmate/c.tmbundle, which had a percent-related highlighting issue before (issue 28): you might have to open a new issue there.
I found this discussion has a plausible explanation. Here I quote:
It's highlighting the % because it's assuming that you're making a printf format string, and that you've made it wrong. Unfortunately there's no way to tell it it's not a printf format string short of changing the syntax file.

Shortcut for clike languages comments not working/implemented?

I'm using the Brackets code editor to code in C++ and I'm having a hard time having the shortcut for lineComment and blockComment working...
The shortcuts are [Ctrl+/] and [Ctrl+Shift+/], they work perfectly for CSS, JS.. etc but not with C++ files.
I looked into the clike.js file in the CodeMirror folder of Brackets, the blockCommentStart, blockCommentEnd and lineComment are correctly defined.
Is it a known issue? has anyone found a workaround?
Before that,I was coding with Notepad++ and this feature was the one I used the most. It's really hard not to have it anymore
You said you saw that blockCommentStart, blockCommentEnd and lineComment are correctly defined in clike.js. From CodeMirror documentation
This file defines, in the simplest case, a lexer (tokenizer) for your
language—a function that takes a character stream as input, advances
it past a token, and returns a style for that token. More advanced
modes can also handle indentation for the language.
It is used to highlight the c++ file. But also it could be used to auto comment line with shortcut. However it is probably not implemented for C++. For this feature comment addon from CodeMirror might be used http://codemirror.net/addon/comment/comment.js since The addon also defines a toggleComment command, which will try to uncomment the current selection, and if that fails, line-comments it.
This was a Brackets bug, but it was fixed in the Sprint 39 release.
(Fwiw though, language metadata in Brackets is defined in a file called languages.json - although Brackets extensions can add to / modify this metadata as well).

Docco ignore blocks of comments

I am using docco as a tool for creating coffeescript documentation.
By default, every comment I make in coffeescript source is treated as documentation and moved to the left (explainatory) column.
The problem is, in my source there are some lines of code commented out, left as alternate options, which I want to remain in the right (code) column.
Is there a way to tell docco- "do not touch that, leave this like it is a normal code"?
"#!" or "#ignore" maybe?
Thanks in advance.
Have you tried it? It will ignore #! hashbang lines.
Ignore hashbangs and interpolations...
l.commentFilter = /(^#![/]|^\s*#\{)/
languages
languages = buildMatchers languages
From the source, line 277 https://github.com/jashkenas/docco/blob/master/docco.litcoffee
If nothing else, you should be able to edit the source to add whatever opt out you would like there.

Highlighting line which are not correctly formated [Eclipse]

So I have some formatting rule to follow, such as :
Space on each side of operator (*, =, +, %, etc)
No space at the end of a line
No more than 80 chars per line
Is there a way to highlight in red line containing formating error?
The eclipse auto-formating tool is no good because either :
It will change to many line (old code not written by me)
or it won't (only my code)
Because I must follow some "colorfull" guideline :
You must change formating error relative to operators in old code but nothing else
Your code must be correctly formated.
Any ideas?
Thanks
You can select which lines of code you want to format. The Eclipse formatting tool doesn't have to run across the entire file. To do this: select the lines you want to format, then press Ctrl-Shift-F.
You could try using the Eclipse Checkstyle Plugin.
You'll need to configure it with just the rules that you need (the default configuration is very strict, so create a new one with just the rules you care about).
This will highlight all lines with formatting issues. I don't think it's possible to ignore old code using the plugin.
Talk to whoever created that coding guideline. It does not make sense in the long run, because editing code in Eclipse will always apply all current formatting rules (which violates that guideline) or none, if you disable the formatter (which leads to you writing bad code).
If there is really no way around that guideline, then you should split your workflow into 2 phases: Reformat all existing code one time to fulfill that operator guideline. You may use any tool you like, even just a regular expression search and replace might be fine.
After that has been done, configure Eclipse to auto-format only changed lines, but always apply all formattings to each changed line. There is no good reason to not re-format the other 75 characters in an existing line of code, if you already touched 5 characters of it.

Emacs ,org, beamer - No definition for class `beamer' in `org-export-latex-classes'

I am following this tutorial, and I am getting this error, when I try to export the presentation to latex:
No definition for class `beamer' in `org-export-latex-classes'
Note:
I installed emacs from the repository in Ubuntu. And following are the related packages that are available in my system:
emacs-snapshot
emacs-snapshot-bin-common
emacs-snapshot-common
emacsen-common
latex-beamer
latex-xcolor
preview-latex-style
texlive-latex-base
texlive-latex-extra
texlive-latex-recommended
Am I missing anything? Do I have to configure other things?
I found I had to run M-x org-beamer-export-to-pdf to get it to work.
Yes., you should define beamer class in org-latex-export-classes. an example how to define is in this blog post
Edit: updating for 2022 and to make reproducibility more straightforward
The original answer is below, untouched since ~2011. I still think the top upvoted answer and accepted answer aren't necessary in 2022, and org-mode is notoriously hard to troubleshoot without walking through fundamentals:
.emacs and other config files
the exact .org file used
In trying to recreate the worg tutorial cited, I think it no longer works as-is. Note that the manual cites a different example now.
In any case, here is a github repo I created with the following to help any others who find this:
a min-config (with no custom org-latex-classes definition for beamer as the accepted answer suggests
a modified beamer_test.org that exports for me using the min-config; some minor tweaks were necessary
the pdf and org file with _ref in the name; when users export, they can compare their generated pdf and tex files (the ones in the downloaded repo will be overwritten) to these references to study differences and better identify issues
Hopefully this better removes confusion for any stumbling on this question.
Final note: I believe my answer below was potentially wrong always, or became wrong at some point in the past 10yrs, as it should be C-c C-e l and P for the final option (beamer pdf), not p (regular latex pdf). I don't remember org-mode that far back to know if p ever worked given the #+latex_class: beamer setting or not.
Edit 2 as ceochronos points out in the comments, my answer was probably always wrong anyway, as I left out the lower case L in the export options C-c C-e p vs. C-c C-e l p. Then again, C-c C-e is an interactive menu with no p option, so hopefully it didn't mess with the minds of too many folks over the years!
The accepted answer shouldn't be necessary anymore. There is a built in function for Beamer export. See this tutorial for details. In essence, just put the following at the top of an org file (before any headlines):
#+startup: beamer
#+LaTeX_CLASS: beamer
#+BEAMER_FRAME_LEVEL: 2
First option brings in some beamer specific options, second makes sure export to LaTeX uses the beamer class, third option means top level headlines are sections, second levels are slides. Change value to 1 for just every top headline being a slide.
Then export with C-c C-e p.
Only exporting to PDF worked after I've exported to a TeX file first with org-beamer-export-to-latex