RStudio: Move Code to Center of Editor - rstudio

I am not sure if this is a reasonable expectation or whether there are other IDEs that have this feature, but when I am writing code in the RStudio editor, once I have written a sufficient amount of code, I am basically always editing at the bottom of the screen:
Is there a way to move the code to the middle of the screen without having to type "Enter" a bunch of times (trailing newlines are code too :-))?

You can keep scrolling by clicking an option in the settings:
Tools -> Global Options -> Code -> Display -> Allow scroll past end of document
This only affects scripts, and not the console.
So, uh.. you got some more of that fake internet points?

Related

How to disable triple click in Visual Studio

Is there a way, either built-in or by third-party extension, to disable triple-click from selecting the entire line while in a text editor? Either my mouse is too sensitive, or I'm inadvertently doing it, but more often than not, clicking a word, then copy / pasting it results in pasting of the entire line -- not my intention and very annoying. Ideally, it could be disabled (aka any click more than 1 just selects the word the cursor is over)
As already stated in the comments the problem is most likely that the word highlighting color is so similar to the color of selected text. So seems like we sometimes deselect a word instead of selecting it. And without a selection Ctrl-C copies the whole line. I had the same issue with JetBrains WebStorm. In Visual Studio for me it was ReSharper.
Changing the color helps. Tools -> Options -> Environment -> Fonts and Colors -> "ReSharper Usage of element under cursor". I made that darker such that selected text is clearly distinguishable.

How to make VSCode editor stop scrolling past bottom of a file?

In the VSCode editor when you pull the scroll bar down to the bottom of the file, all you see is a blank page, since the text has scrolled up past the top of the text editor window. This makes scrolling to the bottom difficult because you can't just pull the scroll bar quickly all the way down but have to carefully position the cursor so you can still see your code.
Very similar to How to make Visual Studio editor stop scrolling past bottom of a file?, but comments have pointed out that question/answer is for Visual Studio. This answer is for VSCode on the macOS and Windows.
The correct answer is seen here: https://stackoverflow.com/a/40588828/1189470
There is a configuration option provided in VSCode for the functionality you specified. To enable it, go to File -> Preferences -> user settings
On the right side of the editor in settings.json paste the below line at the bottom (before closing bracket), save and close.
"editor.scrollBeyondLastLine": false
This will prevent the editor from scrolling beyond the last line.
This is now exposed as a simple checkbox labeled "Editor: Scroll Beyond Last Line" in File/Apple -> Preferences.
If just for readability you would like some space at the bottom of the file - a configurable amount - try this setting as of v1.43:
editor.padding.bottom in pixels
Editor> Padding: Bottom
Controls the amount of space between the bottom edge of the editor and
the last line.
and/or
editor.padding.top // but this isn't sticky in the sense that you can scroll right past the padding top and it is gone. It doesn't stay.

Visual Studio 2015 - arbitrary cursor position on empty line

Initial note: I'm not getting any responses over on superuser to my question, so please allow me to ask this here:
I inherited a VS solution with a bunch of unorthodox settings. I'm not at liberty to wipe out all those settings and start over. So there is 1 setting I want to change back to VS default but cannot find it.
In a normal/default VS c# environment, when you click the mouse on a line of code that hasn't been written yet (empty, no spaces, no code, no tabs), the cursor automatically positions to the beginning of where the line of code should begin. If it's just inside a foreach, if, or etc, it will indent a bit from the left edge according to tab rules, etc.
But in the weird VS settings I have, wherever I click, the cursor positions at that exact spot. So if I click on col 20 of the next line, the cursor remains at col 20 rather than auto-repositioning to col 5 or wherever it should be. This is SO annoying because I can't always eyeball where the cursor should be and I end up clicking at the end of the previous line, then hitting ENTER, at which time it goes to the next line and positions the cursor at the right place.
How can I fix this?
It is controlled by the Enable virtual space option. See Visual Studio options - Text Editor - C#. By default it is off/unchecked.
I resolved this issue by applying Sergey's suggested change (Visual Studio options -> Text Editor -> C# -> Enable Virtual Space [check]), but also enabled (Options -> Text Editor -> C# -> Tabs -> Smart).

how to come back when you are reading code in Xcode?

I have been developing in zend studio and there is a feature I miss a lot in Xcode. When you are reading code in a main function and you want to go in a specific function to read something, you can click in the left area of your current line of code were your are, and a flag-mark appears in that line of code, so you can go anywere else in the code and it will be very easy to come back to that line of code you were before because there is a flag and you only have to click on it and you automatically go back. Does Anybody know a similar way to do this in Xcode?
Unfortunately, this feature was present in earlier versions of Xcode (up to Xcode3 IIRC) and was called "Bookmarks", but it was removed since then.
You can use breakpoints (and disable them) as a workaround, even if it's not perfect. I personally prefer using other tricks, like "Open Quickly" and named tabs.
Alternate trick 1 : "Open Quickly"
One trick is to use Command+Shift+O (or "File" menu > "Open Quickly") to quickly open a file. In the field that appears, you can type:
The name or parts of the name of a file.
Typing "MainViewController" will propose to jump to the MainViewController.h or MainViewController.m file.
Typing "MainVC" will work too, as well as "MainViewCtrl", as long as the order of the letters you type is the same as the full name.
Very handy to just type "ContTVCell" to open the ContactsTableViewCell.h file that is hidden deep in subgroups of my project for example
Similarly, you may also type the name or parts of the name of a symbol, especially a method name.
For example, typing tvcellforrow will list you all the definitions of -tableView:cellForRowAtIndexPath: it could find in your project and let to jump to the one you want
When typing (parts of) the name of a file, adding : followed by a number at the end will allow you to directly jump at the corresponding line
For example, typing mvc:50 will propose you to jump to line 50 of MainViewController.h or MainViewController.m
Another trick : using (named) tabs
Don't forget that you can open tabs in Xcode, which can be very handy in this kind of situation.
When you are editing a file at some interesting position, you can create a new tab to browse elsewhere and go at any other place… and then go back to your first tab to find the code where you left it at the time you switched to the other tab.
Don't forget that you can name your tabs (simply double-click on their title) to give them a more explicit title. You may then quite think of them as "named bookmarks" somehow
Likewise, don't forget that you can detach tabs in separate windows too, if you prefer (for example to keep them around and visible on your secondary screen while you edit another part of your code)
You can even combine this with the "Open Quickly" trick presented above: once you made the "Open Quickly" field appear and typed something into it, instead of just validating using the enter key:
use Alt+Shift+enter to let Xcode present you a small widget that let you choose where you want the file to open (in the current tab, in another tab, in the assistant editor, in a dedicated window…)
use Alt+enter to open the file using the alternate navigation defined in Xcode preferences (Xcode > Preferences > Navigation > Optional Navigation). By default, the behavior when opening a file while using the Alt key is to open the file in the Assistant Editor. Personally I changed that in my Xcode preferences as I prefer to make Xcode open the file in a separate tab instead, which makes Alt+clic much more useful.
Sure, all those tricks with "Open Quickly…" and "Tabs" do not replace the bookmarks feature that you are missing. But they are still nice alternate ways to jump quickly to any position in your code, even any specific line of any specific file in your project, wherever you are in Xcode (even without having to have the Project Navigator visible on the left part of your window), and let you have multiple editors in different tabs to go quickly back to a part of interest in your code
its on top of your editor i have added two pics just check them.
When you navigate to another place in Xcode, say, open a different file, or Command-click and jump to definition, you can go forward and back by swiping right or left on the trackpad with two fingers.
You can also use keyboard shortcuts: Ctrl+⌘+→ to go forward, or Ctrl+⌘+← to go back.
Finally, you can click triangular buttons at the top left in your edit area.
There is a go back button at the top left of the editor!
If that is not good enough, whar I do is misuse breakpoints to set flags in my code. The breakpoint navigator thus becomes a table of flags. It isn't much but there you are.

VS2012 Text Editor Width

Is it possible to change the width of the text editor in VS2012 - I've got a fairly wide screen and use fairly small text so I end up with a lot wasted real-estate in the middle of my screen.
I don't want to turn off word wrap - I just want the wrap to start further right on the line. If that makes sense!?
You can set this with HTML in Visual Studio 2012 but there is no global setting and it's missing in quite a few languages.
You can just put another "dummy" window next to the one you are writing in, so the actual editor window will be smaller. You can put it on the left if you want to pan the text to the right, and to the right if you want to shorten the lines.
I actually found the answer elsewhere; VS doesn't appear to provide this functionality but Resharper does. Resharper -> Options -> Code Editing -> C# -> Formatting Style -> Line Breaks and Wrapping -> Right margin (columns)
I put mine to 200 which fixed the issue
I know that this is not what you are looking for, but I believe it solves the same problem. I too have a fairly large screen and try to make use of it as optimally as possible.
I hate tabbing between code or design tabs and try to avoid that as much as possible.
VS has a feature that permits the user to create Horizontal or Vertical Tab groups and ever since I have started using it, I have found it very helpful. These options are present in the context menu by right clicking the tab or in the VS Window Menu (Menus are seen only if the tab groups feature is not active).
I have created a screenshot with Vertical Tab Groups created as shown below. In this example, I have a overview of both the designer and the code view at the same time.
We can use tab groups whenever there is a dependency such as comparing code, redesigning a module, etc. I know it takes a little time to get used to this feature but try it out and see :)

Resources