how can I hide my comments in an R-script in R-Studio? In R-Studio's console all lines beginning with '#' will be printed. I do not want this.
Related
Duplicate question because I can not comment (Shortcut for commenting in Rmarkdown?)
in Rstudio using shift-cmd(ctrl)-c or the 'comment/uncomment' line option produces a '#' that comments out the line in the editor, but upon compiling does not comment out the line.
using " " comments out the line when compiled, but does not change the Rstudio font, making it difficult to use Rstudio for editing.
Am I missing something?
You can use cmd-shift-c (or ctrl-shift-c on Windows) to produce the comment symbol. The comment tag added varies depending on which section of the document you are working in.
If you are working inside an RMarkdown chunk then # will appear.
To comment out text outside the code chunk with <!-- --> you first need to have some text entered on the line you wish to comment then, with the cursor located anywhere on the same line, try using the shortcut.
<!-- RMarkdown text wrapped in a comment -->
```{r}
# Comment inside code chunk
```
Note commenting outside a code chunk using the shortcut doesn't work for me on a line containing only whitespace. I don't think this was the case in the previous version of RStudio (I'm using Version 1.1.383) but perhaps it's my memory that's faulty!
I have an issue with getting the contents of a tkinter text box. If I paste information into it from Excel (for example), it always adds an empty line at the bottom. I would like to remove that line automatically. This is what I use to get the contents:
contents = inputText.get(1.0, "end-1c")
for line in contents.split("\n"):
line = line.strip()
I initially added a '[:-1]' on the end of that, which works, but only on text that is pasted into the text box. If you type text in manually, then obviously there's no trailing '\n' on the end, so it ends up removing the last character that was typed. Not good!
How can I get it to remove (or ignore) the trailing empty lines? The 'line = line.strip()' in the code further down seems to have no effect.
Thanks, Chris.
Your problem isn't with getting the text, your problem is that pasting seems to add more than you expect. To get text, regardless of how it ended up in the widget, you should use .get("1.0", "end-1c"). There is simply no way to know at the time you are getting the contents of the widget if any extra newlines came from the user directly or from a paste operation. To tkinter, text is text no matter how it was entered.
The only solution is to adjust the paste binding, and even that is problematic because I don't think tkinter has any way of knowing if the clipboard contents are from excel, or from some other source.
If all you really want is to ignore all trailing blank lines, call strip() on the data before calling split("\n")
Textbox was always inserts a blank line at the end. The problem was compounded when editing textbox and yet another blank line was inserted. However during edit you could remove blank lines so you can't use "end-1c" all the time.
The trick was to remove 1 or more extra blank lines after editing:
# Rebuild lyrics from textbox
self.work_lyrics_score = \
self.lyrics_score_box.get('1.0', tk.END)
while self.work_lyrics_score.endswith('\n\n'):
# Drop last blank line which textbox automatically inserts.
# User may have manually deleted during edit so don't always assume
self.work_lyrics_score = self.work_lyrics_score[:-1]
Note however this is with Linux. For Windows you might need something like:
while self.work_lyrics_score.endswith('\n\r\n\r'):
# Drop last blank line which textbox automatically inserts.
# User may have manually deleted during edit so don't always assume
self.work_lyrics_score = self.work_lyrics_score[:-2]
Or whatever the the control code is for DOS/Windows LF/CR (Line Feed / Carriage Return) typewriter days style is.
I am an avid TextExpander for Mac user. I use it to expand code across multiple text editors. I have had one issue that I wanted to run by fellow programmers who use TextExpander for possible solutions.
When I am expanding multiple lines of code on a line that has leading whitespace, TextExpander resets the leading whitespace on all lines beyond the first one.
Example:
If I am trying to expand a debug snippet I use all the time, from an indented line, it appears like so.
echo '<pre>';
print_r();
echo '</pre>';
The first line is indented because that is where I typed the expand abbreviation. Is it possible to maintain the leading whitespace status across all lines?
echo '<pre>';
print_r();
echo '</pre>';
I'm afraid TextExpander can't mimic the auto-indent behavior of your code editor.
If you always enter these at the same indent level, please note that you can use option-Tab to insert a tab when editing a snippet in TextExpander's snippet editor.
If your code editor respects the indent level of formatted text, you could instead change the snippet type from Plain Text to Formatted Text, Pictures using the popup above the snippet editor then choose Format -> Text -> Show Ruler to show the text view ruler, which works the same as in TextEdit and other apps.
If you'd like further assistance, write us at: support#smilesoftware.com
Using TextMate on Mac, the "invisibles" can be displayed by using
View -> Show Invisibles
But the space vs tab characters are not shown, and Preferences doesn't seem to have any entry to change that either. Is there a way to show them? It is because some older coder may have tab or space mixed together so what looks good in the editor may actually be misaligned. (editor shows tab as 2 spaces)
Tab characters are shown, but spaces are not. What's probably happening is that you have Soft tabs turned on, in which case the tabs are converted into spaces automatically.
alt text http://grab.by/grabs/fabaea391dc8bc764636f0ca19a8c38d.png
In this picture there is a tab character, new line, tab character, new line, soft tab, new line
See this thread for an explanation as to why spaces are not shown.
Here is where you can change soft/real tabs.
alt text http://grab.by/grabs/783db3a88609a01c7702cbd250f495c6.png
If "Show invisibles" is activated, you will see a little triangle for each tab, which points to the right. Spaces are not shown at all, you can only see them indirectly, i.e. via the symbol which represents the line break. If the line break isn't the first character after your code of that line, there are spaces in between.
So to make a long answer short: You should already see tabs, however the symbols representing the invisibles are sometimes hard to see.
When commenting out a piece of code in xcode
//code
If you click comment again it adds more comments
////code
does anyone know how to prevent this?
It looks like a bug to me .... if you do command + ] it gets rid of the tabs.. The tabs are the ones causing the issue. Xcode sees the tabs and adds more comment lines. so do command +] twice or until all the tabs are gone. and then you can remove the comments using the command+/ (comment selection command)
When you "click comment again" you have to have the // selected (and optionally the rest of the line).
Usually when you comment the first time Xcode will select the text such that pressing the comment shortcut again will uncomment.
Is nothing selected after you comment the first time?