Problem:
When I toggle a comment in Pydev it adds a space, inconveniencing me to manually correct this indentation. This was not an issue with earlier versions of Eclipse/Pydev. This problem occurs if I use the comment toggle key (ctrl + /) alone, or if I use it in combination with the uncomment key (ctrl + \).
System Versions:
Eclipse Juno (Version: 4.2.2), Pydev 2.7.3
Examples:
a = 4
# a = 4
a = 4
In line 2 I comment that code (ctrl + /). Line 3 I uncomment (ctrl + /). Notice there is a lingering space before the a in line 3.
Redoing this example with the same version of eclipse but using java no spaces are added:
a = 4
//a = 4
a = 4
So, I think this is a pydev issue.
Research:
As I said before, this is not an issue with my Eclipse Indigo / Pydev 2.5 install. Spaces are neither added nor subtracted when toggling comments (ctrl + /).
This appeared on stackoverflow before as an issue in java. The fix provided there had no effect for me (it doesn't matter if I use tabs or spaces):
Eclipse "Toggle Comment" Shortcut Indents on New Projects
This issue has also been reported on pydev source forge:
http://sourceforge.net/p/pydev/bugs/1547/
Work Around:
This is a solution for me, but isn't a true solution to the problem at hand. As suggested in the link above, do the following:
go to (in Preferences): Pydev | Editor | Code Style | Code Formatter
for the "Spaces in comment start?" combobox select "Don't change manual formatting".
Again, this solves my problem but doesn't solve the true problem at hand for someone who would like there to be spaces separating their comment from the comment symbol.
Also, because the default install preference is set to: "At least one space", this isn't an issue you would intuitively know how to fix upon just installing pydev for the first time.
This may not be exactly what you're seeking, but Eclipse (Oxygen with CDT, PyDev)
seems to preserve spacing spacing pretty well when using block comments. (under Source menu)
Add Comment Block Ctrl + 4
Add Single Comment Block Ctrl+Shift+4
Remove Comment Block Ctrl + 5
Ctrl + 4 works nicely in a .py file for Eclipse Photon with PyDev.
For any files which are not .py it may be useful after selecting text to use:
Edit -> Toggle Block Selection
..to manually put your '# ' simultaneously on all the lines where you want it, like in Sublime.
Related
I am using VS code for python and when I am going into a new line and pressing backspace it goes back just 1 space instead of 4 spaces(a Tab). Earlier it was working fine but I changed some setting mistakenly and can't seem to figure out how to change it? How can I make it work?
Edit- I see I can use shift+tab to go 4 spaces but earlier I was able to do it with backspace too.
I just installed Win 10 1809 on my Dell PC, and it seems to run okay. But the first thing I did was start up VS Code. I wanted to run yarn start for my React project, but I had to type it way down in the terminal window, while the prompt was at the top. It worked though.
And when I open any project file, there seems to be approximately 100 blank lines appended at the end of each. But the line numbers don't go down that far and the cursor stops at the last line number. But the scroll bar acts as if those blank lines are there.
So I'm guessing the same number of blank lines are being added to the terminal too. But in the terminal window, the cursor is positioned at the bottom of the scrollable window.
What's going on? Is there a fix?
EDITED:
I see that I can scroll the file's window up until the cursor and last line is at the top, but no further, regardless of the window size. Maybe this has always be the case, and I never noticed. But now because of my terminal problem, I am suspicious of everything and checking for any abnormalities. So I don't think that extra blank lines are being added to my files. Sorry for the mistake.
But the terminal problem persists. The screen clip below shows the terminal display after I enter "yarn start". The typed input shows up way down from the initial prompt, and the blank area is a long string of "0D0A" characters. Sometimes I can click on "kill Terminal" and then start a new one and the new one works correctly. But not always.
Still trying to figure this out.
Can you share snapshots for your problems?
This is some hint for your problem
In VS Code, type
Linux / Windows: Ctrl + Shift + P
MacOS: Cmd + Shift + P
Type Settings to go Settings
At settings, search end of file, at here you can configure something for your problem with auto append blank lines each file
I hope it will help you :)
Your Terminal Problem is described as Bug in VS Code Issues.
As of July 2019 the intergration is pending due to stability problems.
https://github.com/Microsoft/vscode/issues/57803
Addendum (August 2019):
The Problem seams to be fixed with VS Code 1.37.1 and Windows 10 Patchlevel 1903
Did you try uninstalling and reinstalling?
Going back to your questions.
What's going on? No idea.
Fix. Use this extension https://marketplace.visualstudio.com/items?itemName=rintoj.blank-line-organizer
or
Open Visual Studio project and collapse all the folder and make it handy.
Now press “ Control + Shift + H “ key combination and you can see the Popup which shows Find and Replace options.
In the Find place input “^&\n” combination and select Use Regular Expression checkbox without fail as this input will mainly work with the regular expressions only.
In the replace field leave it empty so nothing will be replaced rather remove the empty blank lines.
In the input Find field we have give ^ for Start of the line and $ for end of line and \n which is for new line break.
source for second solution: http://www.f5debug.net/post/2015/01/03/How-to-remove-Blank-lines-between-codes-in-Visual-Studio-Code-editor.aspx
The extension will be useful overall especially when working in a team project where a lot of people might be leaving too many empty lines. Good luck
Not sure whether there would be an existing shortcut for this or not, but if so, what is it, and if not, how can I create one?
I want it to essentially toggle the wrapping of slash-star comment tags, so if the line is commented already, it becomes uncommented. Eg from:
/*padding-left: 10px;*/
to
padding-left: 10px;
There are 2 standard actions for working with comments:
Comment with Line Comment Ctrl + /
Comment with Block Comment Ctrl + Shift + /
CSS does not have single line comments, only block comments, but Comment with Line Comment works just fine: it comments and uncomments current line (or selected lines) by applying or removing comment for each line individually.
Block comment works with selections only and applies single comment to whole selection.
P.S.
Those shortcuts are for Windows using Default keymap. For other OS / keymaps check it in Settings (Preferences on Mac) | Appearance & Behaviour | Keymap (that's for PhpStpm v8.0.2, for 8.0.1 and older the settings path is slightly different)
Is there a way to comment various lines at the same time in Xcode IDE? Selecting which lines to comment, then clicking somewhere et voilá.. the /* ... */ characters wrapping the code.
Thank you.
Command + Shift + 7
or
Command + /
This inserts // in front of every selected line.
Xcode Version 6.1
Shortcuts:
To Comment: Select the code to be comment, ⌘ + /
To uncomment: Select the code an press ⌘ + /
Also see taskbar Editor>Structure "(un)Comment Selection" as user 2137640 pointed out.
The answer is actually very simple if you want to comment a continuous sequence of lines. Select the consecutive lines, then simply press ⌘ /.
I have no idea how to comment multiple non-consecutive lines. Maybe somebody else can help with this, if it is even possible (I doubt it.)
I've been using the Command + Shift + 7 for years, but now in Xcode 13.1 it just started to open the help menu instead of commenting the selected block.
Apparently the new command for commenting a selection of code is:
Command + Shift + ?
Edit:
Another solution is to deselect "Show Help menu" in settings > keyboard > App Shortcuts
There is such a function in the menu. Try: Edit->Insert Text Macro->C->Comment Section.
It will create a (multi-line) comment around the currently selected text.
However, using the menu is probably often slower than manually inserting the comments. But, you can also bind a key to the menu item via the preferences key binding settings.
For single line Comment use ⌘+/
For multiline Comment you need to install CComent plugin
to install plugin manager use alcatraz
new Xcode 14:
Keys: Command + '
in Xcode 7.x
Shortcuts:
To Comment: Select the code to be comment, ⌘ + /
To uncomment: Select the code an press ⌘ + /
Got it! You have to un-indent the lines so the comments are the first character on the line, not a tab or whitespace - then pressing CMD+/ works. Just tried it in XCode 5.1.1, works like a charm.
This worked !
Higlight the desired lines then press Command + /
The same rule goes for uncommenting.
For xcode 8 ->
sudo /usr/libexec/xpccachectl
restart your computer
In Turkish keyboard cmd + *
You can use uncomment and multiline comment.
Curly brace matching was pretty easy to turn on. How can I turn on parenthesis matching in Xcode?
on Xcode Version 6.1 (6A1052d), you just need to double click on one of the parenthesis and the entire code that the parenthesis is scoping out is highlighted.
for example, if you have a code like the one below and you double click '{' or '}' bracket the entire code in their scope is highlighted :
if(condition == true)
{
//do something
}
Choose editor -> code folding -> focus
Edit
In XCode 9 the only solution is to put mouse over parentheses while pressing command button. Only this works.
Previous
To extend the other answers
it is possible to roll in/out code inside brackets.
Choose Editor > Structure > Balance Delimiter
url
Nevertheless, as already written earlier, the major feature is
Editor > Code Folding > Focus Follows Selection
press command key and its hover the brace and parenthesis ...
You must be running Xcode in Snow Leopard and install Xcode from the Snow Leopard disc that you got at WWDC. If you did not get a Snow Leopard disk, then you are out of luck unless you find one elsewhere.
The version of Xcode needed is 3.2 and the other components in the about page are:
Component versions
Xcode IDE: 1600.0
Xcode Core: 1599.0
ToolSupport: 1591.0
Please have a look at below answer for Xcode 9.0 and above:
Xcode highlights an opening delimiter (brace, bracket, parenthesis) when you move the cursor left-to-right over the matching closing delimiter. The highlight animation lasts about 1 second total, which is plenty in the case where you need a hint (and as you say the other delimiter is nearby).
If you need a more persistent indication, you can double-click either the opening or the closing delimiter, and Xcode will select both delimiters and their contents. (You can also use this, for example, to get quickly to one delimiter from another, even if they're far apart — double-click the delimiter you can see, use the left or right arrow to get the other end of the selection.)
With latest xcode13 we can permanent active this option with
"Xcode" --> "Preference" ---> "Text Editing" and by enabling "Code folding ribbon"
Thanks