I often find myself adding a new package midway through the code so I need to add using Pkg1 or import Pkg1. But then this code should sit up the top, so I end up scrolling up to the top, type the using code, and then lose track of where I was in the code.
In some python extension, the import statement can be sent to the top for the user.
Is there a vscode extension to do that for julia code?
You can use ctrl+g to travel through lines in VScode.
ctrl+g line 1
ctrl+g line x /*replace x with the line you were*/
Related
I've been transitioning to using VS Code for my python projects after previously working with the full Visual Studio, and some of the key bindings/features I'm used to in Visual Studio I can't find the equivalent for in VS Code. I'm not sure if the bindings are different or if the feature doesn't exist.
One feature in particular that I can't figure out is if it is possible to do multi-line select past line endings. In Visual Studio, using Alt + Click + Drag, lets you create a multi-line cursor or box selection, that can extend past line ends, implicitly adding spaces as needed so that the right-most side of the box stays uniform. In VS Code, if you drag the selection past the end of a line, the selection box won't go past the end of the line, even if other lines in the selection extend past it. In Visual Studio, this feature even goes further, as you could Alt + Click + Drag even in areas with no characters as all, creating a multiline cursor or box selection to the right of all existing line ends.
This isn't an essential feature, but it's very handy in making code easy to read. For example, when assigning several dictionary entries all at once, with varying key lengths. Is it possible to do something like this in VS Code?
Edit: The feature I'm looking for is virtual spaces (thank you Mark for providing the feature name), which seems to be an outstanding feature request in VS Code.
The short answer is no, vscode does not have a box select, past line ends, built-in. VS Code does not have the concept of virtual spaces which would be necessary to make this work yet.
Below is the issue, lots of comments, not that many upvotes. Upvote it.
https://github.com/microsoft/vscode/issues/5402
I want visual studio code to suggest an autocompletion for an entire line if I start typing the first few characters of any line already in the file, regardless of the content of the existing line. So if this is the content of my file:
this is a line with whitespace
this,is,a,comma,separated,list
And I type this on a new line, I would get a pop-up like any other autocomplete suggestion and I could fill in either of the lines above. How can I do this (and if I can't, is there another editor that has this ability)?
The extension Line Completion does what you want.
You have to configure for which files (language identifiers) it should perform these suggestions. (To prevent to much calculation on large files where you don't use it. See the README page.
in the terminal(powershell integrated terminal) i display with format-table the output of a deployment (pl1 code).
The warnings etc. are displayed with the line number where they appear. Is it possible to make a clickable link(on the whole line with the warning or just on the line number) to directly jump to the line in the source code?
Thanks!
Found out that it is possible by just writing the full
C:\xxx\_yyy\zzzz\tttt\1111\SRCFILE.PLI:10:4
or relative path followed by position
..\zzzz\tttt\1111\SRCFILE.PLI:10:4
I'm trying to use the multi cursor functionality of vscode on a large(ish) file.
the file is too large to select every line individually with ctrl-alt-up or down. In sublime-text I would select everything and push ctrl-shift-l. Is there a similar thing in vscode. I've tried using a regex search for ^, but that gives me an error stating "Expression matches everything".
The command Selection / Add Cursors to Line Ends altshifti will put a cursor on every line in the current selection. (For mac use optshifti)
Tip: You can pull up the keyboard shortcut reference sheet with ctrlk,ctrls (as in, those two keyboard combos in sequence).
(For mac use cmdk,cmds)
Hold Alt+Shift and select the block. Then press End or Right button.
You get selected individual lines.
I use version VSCode 1.5.3 in Windows.
Hold Alt+Shift+i
Hold Home (fn+-> Mac) for right-most or End for left most(fn+<- Mac)
This feature is actually called split selection into lines in many editors.
Sublime Text uses the default keybinding, CTRLSHIFT L
VSCode uses ALTSHIFTI
For Atom you actually need to edit your keymap to something like this
'.platform-win32 .editor, .platform-linux .editor':
'ctrl-shift-L': 'editor:split-selections-into-lines'
Real Lines vs Display Lines
First we have to understand the difference between Real Lines and Display Lines to completely understand the answer of the question.
When Word Wrap is enabled, each line of text that exceeds the width of the window will display as wrapped. As a result, a single line in the file may be represented by multiple lines on the display.
The easiest way to tell the difference between Real Lines and Display Lines is by looking at the line number in the left margin of the text editor. Lines that begin with a number correspond to the real lines, which may span one or more display lines. Each time a line is wrapped to fit inside the window, it begins without a line number.
Cursor At the Beginning of each Display Lines:
Cursor At the Beginning of each Real Lines:
Answer to the Question
Now that we know the difference between Display Lines and Real Lines, we can now properly answer the actual question.
Hold AltShift and select the text block.
Press Home to put cursor on the beginning of every Display Line.
Press End to put cursor on the end of every Display Line.
Press HomeHome (Home twice) to put cursor on the beginning of every Real Line.
Press EndEnd (End twice) to put cursor on the end of every Real Line.
Please understand that AltShiftI put cursor on the end of every Real Line.
Install the extension Sublime Commands.
[Sublime Commands] Adds commands from Sublime Text to VS Code: Transpose, Expand Selection to Line, Split into Lines, Join Lines.
(Don't forget to add the keybinding(s) from the extensions details page to your keybindings.json)
Doesn't VS Code already have a "split into lines" command?
Yes, yes it does. However it differs from the one in Sublime.
In VS Code, when you split into lines your selection gets deselected and a cursor appears at the end of each line that was selected (except for the last line where the cursor appears at the end of the selection).
In Sublime, when you split into lines a cursor appears at the end of each line (with the same exception as in VS Code) and the selection is divided on each line and "given" to the same line.
I have the same problem, i'm used to Alt + drag to do 'box selections' in visual studio but it does'n work in code.
It seems to be impossible for now to do it differently than by selecting every single line.
However plugins should be supported soon so we will likely see a plugin for this if not implemented directly by microsoft.
From visual studio uservoice forums:
We plan to offer plugin support for Visual Studio Code. Thank you for your interests and look for more details in our blog in the coming weeks. http://blogs.msdn.com/b/vscode.
For the preview we are looking for exactly this type of feedback. Keep it coming.
Sean McBreen – VS Code Team Member
I have an issue that is driving me insane with Sublime Text 3. When I select multiple lines by clicking on the side of the line and dragging, I then hit tab to correct the indentation, but then I want to move the entire line to another spot except I have to re-select it because the first line is only selected from where the text starts, not where the line starts.
Let's see if I can illustrate this... Below is the lines I have:
Text Line 1
Text Line 2
I select them (selection shown using *)
*Text Line 1
Text Line 2*
I indent the lines and now the selection looks like this:
*Text Line1
Text Line 2*
Notice the selection starts with the text. I want the selection to stay at the beginning of the line like this:
* Text Line 1
Text Line 2*
I have searched everywhere but apparently I'm the only one that is bothered by this. Every other code editor I have used does it the way I want.
You can achieve this will a small Python plugin:
Tools -> Developer -> New Plugin...
Replace the contents with the following:
import sublime
import sublime_plugin
class IndentSelectWholeFirstLineEventListener(sublime_plugin.EventListener):
def on_post_text_command(self, view, command_name, args):
if command_name == 'indent':
if all(not sel.empty() for sel in view.sel()):
if all(view.line(sel.begin()) != view.line(sel.end()) for sel in view.sel()):
new_selections = []
for sel in view.sel():
new_selections.append(sel.cover(view.line(sel.begin())))
view.sel().clear()
view.sel().add_all(new_selections)
Save it in the folder ST suggests, as fix_selection_after_indent.py
How this works:
Immediately after the indent command is executed, if all the selections are not empty, and they all span multiple lines, extend the selections to cover the entire first line of each selection.
There's a fix...
There is a plugin called FixSelectionAfterIndent, I just found it (again) because SublimeText4 has the same problem and I already forgot how I fixed it in ST3. So anyone looking for a solution to this (veeeeeeeery annoying) problem, here it is. (You can install it via Package Control, but I like to put links in my answers, for no particular reason.)
https://packagecontrol.io/packages/FixSelectionAfterIndent