VS Code can do that?
vscodecandothat.com
vscodecandothat.com
- In the Git view, select a modified file, select some lines of code you modified, cmd shift P, Git: Stage Selected Ranges. I dropped my dedicated Git GUI since I know this trick.
- If you spend a lot of time coding in React, and have half of your files named index.js, do yourself a favor, go in the settings and add "workbench.editor.labelFormat": "short" (display the name of the file's folder in all the tabs)
- You can preview markdown files natively (button at the top right corner).
- Real time collaborative development: https://marketplace.visualstudio.com/items?itemName=MS-vsliv...
Re the git stuff though- one place that I'm pretty sure emacs is the uncontested champ is in git integration via magit. I'd be inclined to recommend using emacs as their git interface even to people who want to use a different interface for everything else. It is that good, and IMHO the only git porcelain that is strictly better than the standard git porcelain.
Evil-mode solves that, and just as magit is better than git evil-mode seems, to me, better than vi. Emacs is better than ever (though you do need to use auto-formatting for languages like JS that change a lot- there is no emacs mode that has kept up with ES whatever. Luckily emacs makes it easy to use formatters like prettier on a per-buffer basis.)
Emacs users can tell that joke, but they have deliver it with a wry smile. Evil-mode users can tell that joke with a knowing laugh.
On the "highly custom" level, I have a work-in-progress script that takes a URL, sends it to a Splash server, and returns the rendered HTML to eww for viewing. This is great for annoying SPAs like the article that spawned this conversation.
My current goal is to swap out my development MBP with an eInk tablet and bluetooth keyboard. Success will be measured as a function of productivity and weather-/water-/environment-proofing of the device; the goal is productivity in full sunlight and/or under water. Emacs will have a central role in that. Just need to find an eInk device with adequate screen refresh rate and Bluetooth support....
vim $DOCUMENTATION_URL (curls the page and opens in vim)
vim-rest-console
:terminal (new!..ish. Works great.)
Every package developer makes choices about how their package works (and built-in behaviour too), but sometimes that clashes with what you want, or is somehow inadequate.
It's those small conveniences that have a disproportionate impact.
I'm not saying you can't do similar in vim or there aren't other ways to achieve the same goal, I'm saying that over time, those minor improvements have a huge impact.
Here's 2 examples:
1) Splitting a window horizontally by default splits 50:50 but on a 16:9 monitor I usually want the new buffer (right) to be smaller than my current buffer (left). So I override the defaults.
2) I use paredit for lisp based languages, but (as far as I'm aware) there's no built in-command to copy (or paste) the s-expression surrounding the cursor's current position.
I often find myself wanting to do exactly that e.g. in a let or a cond form in Racket. So I wrote a couple of small functions to do just that, bound them to keyboard shortcuts and I've now made a minor extension that fits exactly what I want to do. Since lisp is based on s-expressions it turns out this extension to someone else's package is incredibly versatile and useful.... TO ME!
(let [<CURSOR>(x (some-function with args)]
I press my chosen key-combination and it becomes (let [(x (some-function with args)]
[<CURSOR>(x (some-function with args)]
ready to edit the new s-expressionThere are other similar commands in the category, like a" for selecting the interior of a double-quoted literal and such.
They are documented under ":help visual-operators".
But that said - it does it's job very well and magit is certainly excellent software for those that are interested in that interface.
But when it comes to magit I'm not so sure. I'm inclined to think that magit is _strictly_ better than any other git interface, so much so that even if you don't like emacs you should suck it up and use magit as your git porcelain, even if you use a different editor for everything else. Magit is that good- I just gave $100.00 to the project, and I never donate to open source stuff. It is that good.
I don’t mean “it’s not my preferred git client”. I mean “I’d rather use almost anything else”.
Why? Because it requires emacs interface, concepts, and controls. And unless you’re ok with those it’s not better at all. In fact it’s _strictly_ worse.
That said: if you like emacs I think you’re correct, it’s almost certainly the best there is.
Others, such as myself, suffer it only when compelled by an instructor.
tig status=> 1 to stage line, u to stage a hunk, \ to split hunks, ! to revert get() {
return new Promise((resolve, reject) => {
fetch(`${baseAPI}/heroes`)
.then(response => response.json())
.then(json => resolve(json))
.catch(err => {
reject (err);
});
});
}
Why not just: get() {
return fetch(`${baseAPI}/heroes`)
.then(response => response.json());
} async get() {
const response = await fetch(`${baseAPI}/heroes`);
return response.json();
} async get () {
return await (await fetch(`${baseAPI}/heroes`)).json()
} function fetchPost(uri, body) {
return new Request(uri, {
method: 'POST',
mode: 'cors',
headers: {
'Authorization': 'token 123412341234'
},
body: JSON.stringify(body)
})
}
function fetchStatus(response) {
return response.ok ? Promise.resolve(response) : Promise.reject(new Error(response.statusText));
}
fetch('https://httpstat.us/500')
.then(fetchStatus)
.then(function(result) {
console.log(result)
})
.catch(function(err) {
console.log('BAD:', err)
});
https://medium.com/@luminarious/i-was-trying-out-fetch-liter...(Option)Alt-Cmd + Down or Up arrow key
From there, you can use arrow keys as normal, but instead of controlling one carrot, you control all the ones you created. So if I use the shortcut key to move to the next word, they all do, same with end of line, or what have you. In the past I had to use regex in my editors to extract quoted text in each line... now I just use multi-select. Each carrot can also be created with the mouse in the Selection menu.
Edit: Apparently it's a feature lifted from Sublime and in other IDEs - thanks!
Alt + Shift + A
You can for example put your cursor on a word, spam ctrl+d (of press alt+f3) to select all instances of that word, and start editing them all at ones, no matter where they are. They don't have to be perfectly in a column. You can also copy X items from anywhere, and if you have X cursors again somewhere else and paste, they'll each go in their respective slot.
That and arbitrary window splitting (split any pane horizontally or vertically) are two features I really miss when they're not present. The latter's surprisingly hard to find; Sublime and VS Code don't do it (Atom does).
https://visualstudio.uservoice.com/forums/121579-visual-stud...
Multicursor is amazing.
One thing it's been great for:
I have code like:
byte b1 = array[0];
And I want to do this for 16 bytes. Control + D to duplicate 15x. Double tap control, hit up 15 times - now there's a cursor at every row. Hold control, hit right (jump by word), index to end of 'b1' on each line. Ctrl + shift + a, 'increment duplicates' - now every line is 1, 2, 3, 4... 16. `ctrl + right` my way to the index key and do the same thing.
It's awesome.
edit: I just found 'duplicate and increment' :o
But I wasn't doing this for a loop unroll.
I had a fixed size array that I wanted to serialize/ deserialize to/ from capnproto - there are no fixed size arrays in capnproto, so I wrote a message that just had b1, b2, b3... b16, and then some code to pull it out into a statically sized array. It allowed me to pull a bunch of bytes into a much larger statically allocated array without any allocation or bounds checking.
I've been using it in editors since well before VSCode existed. It's very nearly a requirement for me to use an editor now.
You must do some kind of programming I've not encountered in my many years. While my editor of choice can do this, I would have no idea how, because a feature like "increment duplicates" is needed so infrequently that I would never remember the shortcut.
There are appropriate plugins available for my editor, but I've never felt the need to install them.
Formatting is another.
Boilerplate code, for example today I had to implemented code like this:
impl Into<Node> for ProcessNode {
fn into(self) -> Node {
Node {some_boilerplate(self)}
}
}
I had 6 node types. Using multiple cursors I:* Implemented it once
* Duplicated it 5x
* Copied the names of the types I needed to impl for
* Attached a cursor to each impl
* Used ctrl + left/ right to word-jump, and past in the appropriate area
Now it's not like this saved me more than a minute or two, but this sort of thing is extremely common in my experience, across languages.
for x in type1 type2 type3 type4 type5 type6 ; do
cat <<!
impl Into<$x> for ProcessNode {
fn into(self) -> $x {
$x {some_boilerplate(self)}
}
}
!
done
Now do a line-oriented visual select of all the lines from for to done (using V + cursor movements). Then pipe to shell with !sh[Enter].Poof! The above is replaced with the following:
impl Into<type1> for ProcessNode {
fn into(self) -> type1 {
type1 {some_boilerplate(self)}
}
}
impl Into<type2> for ProcessNode {
fn into(self) -> type2 {
type2 {some_boilerplate(self)}
}
}
impl Into<type3> for ProcessNode {
fn into(self) -> type3 {
type3 {some_boilerplate(self)}
}
}
impl Into<type4> for ProcessNode {
fn into(self) -> type4 {
type4 {some_boilerplate(self)}
}
}
impl Into<type5> for ProcessNode {
fn into(self) -> type5 {
type5 {some_boilerplate(self)}
}
}
impl Into<type6> for ProcessNode {
fn into(self) -> type6 {
type6 {some_boilerplate(self)}
}
}
Don't write in some insane boilerplate-driven programming language in the first place. Anyone proliferating this kind of duplication (whether with multi-cursors or shell here docs or any other way) should be flogged.For your example, this is the kmacro I ended up with:
;; Keyboard Macro Editor. Press C-c C-c to finish; press C-x k RET to cancel.
;; Original keys: 2*M-f M-DEL b C-x C-k TAB C-a 2*C-k 2*C-y C-p
Command: last-kbd-macro
Key: none
Macro:
2*M-f ;; forward-word
M-DEL ;; backward-kill-word
b ;; self-insert-command
C-x C-k TAB ;; kmacro-insert-counter
C-a ;; move-beginning-of-line
2*C-k ;; kill-line
2*C-y ;; yank
C-p ;; previous-line
(after you've created a macro, you can get the above by doing M-x kmacro-edit-macro.) YP<Ctrl-A>l<Ctrl-A>
That can be recorded into a register (say "a") with qaYP<Ctrl-A>l<Ctrl-A>q
then replayed with @a, and further repeated with @@.This is nothing new; I was doing this in Vim 20 years ago.
I've had issues in IDEs where they have shitty implementations of multicursor that break that example.
Super handy when you want multiple cursors to line up at the start of every line (by default vscode will wrap the cursor around to the end of the longer lines if you try to move around with the arrow keys).
There's about 20 other extensions I routinely use, which I documented at https://nickjanetakis.com/blog/switching-to-vscode-from-subl....
Pressing home doesn't always put you at the true beginning of the line. It will put you at the first non-whitespace character.
It only took using a keyboard for about 22 years to learn pressing home more than once has benefits.
Thanks!
Additionally, there is a case where if you don't select the last line until the end, you end up in a state where the last cursor is already at the beginning. If you press "Home" now, you end up having that last cursor at the beginning of the line - and the other ones at the indentation level (see https://github.com/Microsoft/vscode/issues/14919#issuecommen...)
(Disclaimer: Author of the mentioned plugin, so I am heavily biased against my own workflow and saving-keypresses-obsession :P)
"keyboard.dispatch": "keyCode"
and see if it helps.Still found 2 useful things for me, Parens colorizer and settings sync via Github Gist.
I'm also using it as my main editor on my Windows box at home where don't do serious development.
My only real annoyance is that I seem to run into multiple addons that can't be properly installed for one reason or another and sometimes "Ignore this" doesn't work and then the popup gets stuck and you can't see the top three lines...
Apart from that it's been really nice for Rust, Go, and Python.
The newest version has smaller popups on the bottom-right of the window, and that was a nice surprise for me.
What is your setup? Is it system wide or do you configure it manually for each project/workspace/folder?
https://about.sourcegraph.com/docs/integrations/editor-plugi...
(And FWIW, I have used Jetbrains products before I used VS Code.)
I'm early on in evaluating ElixirLS and vscode-elixir but have run into some issues with both.
I do prefer adding a .prettierrc to projects, though, instead of inside vscode options (user or project) like what is suggested here. That way my teammates and I can use the same settings, even if they don't use vscode.
But the costs are more than offset by the benefits. I didn't realize how much of a cognitive burden thinking about formatting was until I stopped thinking about it, and it turns out that using formatting to signal intent is perilous when people don't agree on how formatting signals intent.
I'm pushing to have Prettier used across all our JS code- there is some resistance to the idea of running it across a several hundred k line non-prettified codebase and some resistance to the idea of using it at all. And this causes problems. Prettier is best when you use it for everything.
But I'm pretty sure we'll eventually just move to prettification. It seems like the right thing to me, and I'm generally right ;). Anyway, thanks for Prettier- I am not actually a huge JS fan despite mostly writing it professionally, but Prettier does away with some of my complaints about JS, and just generally makes my life easier.
Thank you
The cognitive load it costs to worry and fret about code formatting....
(thank you)
Add this to your settings:
``` "search.location": "panel", ```
Not perfect, but it's a start.
https://marketplace.visualstudio.com/items?itemName=adammara...
I've always wished this key at least had an LED indicator along with Caps Lock.
One thing I'd like from the past is a blinking block cursor.
Can you explain the exact scenario you use it in, I honestly can't think of a scenario where insert is useful.
It’s hard to come up with exact examples because it’s actually subconscious and as automatic as touch typing for me. Thinking back, when I’m on one line with the cursor maybe halfway through, I’ll hit down arrow, alt arrow to the word I want to rename, hit insert, type over it, hit insert. I think I did it when trying to clarify some documentation. I’ll be on the lookout in the near future, but unlikely to report back here unless it happens to happen really soon.
It hasn't been updated in over a year, but I've yet to have any issues with it.
Want to collect all values of something as your code runs? conditional breakpoint: `x = (x || []).append(val)` and then print it whenever you feel like it. Log breakpoint? spit it out each time and... browse by hand? hope nothing's logged in between? bah.
>Teach people to use the conditional breakpoint and just enter `console.log(...)` instead, it's overwhelmingly more powerful.
If you're going to print things for insight at breakpoint time, wouldn't it make more sense to just use watch expressions?
But very frequently yes, all you need is a breakpoint and an expression, and hit "continue" a few times. I absolutely do that when I can.
---
As to "just a wrapper for console.log", yes. It's a bit of an infection, though I'm not seeing as many as I used to, so maybe we're fighting it off. but e.g.:
jetbrains has stuff like "evaluate and log": https://www.jetbrains.com/help/phpstorm/configuring-breakpoi...
Visual Studio has "condition" and "action" options for breakpoints: https://msdn.microsoft.com/en-us/library/5557y8b4.aspx one of which is "log a message": http://www.visualmicro.com/page/User-Guide.aspx?doc=Working-... (mindlessly copying this UI, because what VS does is Good™ (it generally is!), used to be more common from what I can remember)
even Chrome [1] and MDN [2] refer to conditional breakpoints, but only mention "will stop when condition is true", not "by the way you can mutate state in here, call funcs, anything you like".
[1]: https://developers.google.com/web/tools/chrome-devtools/java...
[2]: https://developer.mozilla.org/en-US/docs/Tools/Debugger/How_...
---
It's oddly crippling to not know this kind of stuff. Ever had a bug, and you wanted to see how it would behave if var X was the right value? You can just override it in a conditional breakpoint and "fix" the bug without rebuilding, to see what happens.
Thankfully there are at least a handful of people who have realized this, despite docs essentially never calling it out: https://davidwalsh.name/debugging-conditional-breakpoints
In many languages, a debugger is very nearly a REPL. Wish Java would have a REPL? Sure, a simple CLI command would be nice, but I've done "live" coding of android apps for years. Just add a periodic callback to the main thread with a disabled breakpoint - once there, modify your views in the expression editor, and your app - on your phone - updates in the very next view tick. There are limitations, like (kinda) not being able to import new things, but they're not hard to work within and the time savings can be immense.
No. This stance is complete nonsense. People who don't want to learn how things work won't learn either way, but an IDE can at least make them safer and more productive. For people who do, an IDE can magnify your abilities quite a lot. All of which is true for any (decent[1]) tool in any field.
[1] here, have a twitter rant. You're advocating for the Hole Hawg: https://twitter.com/myrrlyn/status/980148201456943104
I get that it's not for everybody but being so against it is something I really do not understand.
Why use color schemes or different fonts at all then?
It's a simple package, but it works very well.
I have got to check out the docker features as well.
I really like VSCode. MS is innovating in UX.
It keeps getting better and better and better month by month and it now even knows how to fix small stupid mistakes like a missing this. when trying to access a field in ts etc.
Well, maybe it’s my extensions that made it slow.
That said I wish somebody would make an IDE that would tightly integrate IPython so I could get IDE autocompletion in a paused test. I spend way too much time writing code in IPython prompts and copying it back.
Edit-to-add: with your downvote you are invited to explain why/if I'm wrong.
A: No.
Long A: Org-mode is plain text. So it org-modes, but not in a meaningful way.
https://github.com/ajtoo/vscode-org-mode
I've used it over Emacs for simple use cases without any real issues, and the project's under very active development.
<body>
<div id=app></div>
<script type=text/javascript src=/static/js/manifest.14a76fad9b304f57d579.js></script>
<script type=text/javascript src=/static/js/vendor.ffa8aef8ba29f634abaf.js></script>
<script type=text/javascript src=/static/js/app.08230312c2e739a44ea1.js></script>
</body>
Web developers: Please, you can do better than this.Front-end developers don't tend to view the web with NoScript. Just like 99% of users don't view the web with NoScript.
I'm a back-end developer, but, when I wanted to indent that HTML in order to post it, I switched over to the instance of vscode that I virtually always having running in order to use its pretty printer.
1 out of 15 examples (the Docker one) don't involve HTML or JS. (And backend JS devs are generally pro-JS so likely aren't using NoScript either).
Do you use NoScript? Maybe you do and you're the <1%, but fact is even if you do, both you and GPP turned it off to view the site already ...
That a simple document with embedded videos "needs" js to load at all is sheer lunacy. The modern web is a massive house of cards. I don't want to be uncivil but I find it very hard to understand how anyone thinks they're doing good work after they create a simple (and useful!) web document that requires javascript to load.
If you're using Javascript to make a web application, fine, clearly there's no reasonable alternative. But if you need Javascript to produce a web document, what are you doing? I wonder how much more electricity is being consumed annually processing utterly pointless Javascript.
Not to mention the huge accessibility benefits that can come from changing the way a site behaves (not just visually but in terms of things like tab and focus behaviour or separating components out) for disabled users. Doing that reliably and effectively for all content on all devices is much easier if you can identify the needs before downloading the content which means JS-loaded content and so it can come down to deciding whether to annoy NoScript users or disabled users.
Also, IME, disabled users hate javascript. But my experience is limited to a few vision impaired folks.
That said, given my experience of running the web with NoScript, I'd be surprised if those sites that double the usage when they can't detect these things come anywhere close to eating up all the bandwidth I'm saving by not loading auto-playing video ads.
> JS is a big security/privacy risk.
No, 3rd party JS (and 3rd party cookies, JS regardless) allow you to be tracked. And ad-blockers deal with that. Blocking 1st party JS is of tenuous benefit w.r.t security/privacy.
Blocking all JS lets me click on any link fearlessly.
https://github.com/gorhill/uMatrix/wiki/How-to-block-1st-par...
I do agree that there is no contract saying you should only serve HTML on the web. But still, you can do better than this.
I mean Mozilla's campaign asking users to send complaints to each and every webmaster writing IE5-only sites. It somewhat worked.
I'd replace the snark with additional details so the author could attempt to reproduce your issue.
"Websites should not unnecessarily require JavaScript."
Can it not be unresponsive if you have a mechanical disk or a weak CPU?
Ooops, I'll stick to Sublime
I used to feel the same way early in my career. Now I don’t feel the need to be in a rush all the time.
It's usually best if one knows a few different tools designed for different scenarios. Right tool for the job.
Nobody is trying to sell VS Code to you.
Well, it is 2018. Mechanical disks?
I'm not saying that it wouldn't have been as successful, but we're here, now, and it is. It's a great product regardless of the fact that it's written with HTML/CSS/JS.
Why not? Didn't hurt ST or TextMate much (though them being closed source did). And we still use Vim, written in C, 40+ years on, and it has tons of plugins...
>Would Microsoft have continued investment in the product if it hadn't?
MS developed Monaco for over a decade, with very little adoption, so why not?
Vim has a pretty huge community of plugins, and with NeoVim that plugin development has greatly accelerated. Intero, Fireplace, Vim FSharp (which works on regular Vim as well), and NeoComplete are excellent, and make NeoVim competitive with a lot of IDEs in my mind.
Part of the reason I don't use VS Code is that I really don't feel the need to run an instance of Chrome just to edit text. On my Mac, after loading a relatively large FSharp file, with FSAutocomplete (which is not known to be particularly efficient software), in NeoVim, it's taking so little CPU on the NVim side that it doesn't even register in Activity Monitor or `ps`. The same file loaded in latest version of VS Code (downloaded about thirty minutes ago) with the Ionide plugin is taking about 8% of the total CPU power.
With computers as powerful and wonderful as they are nowadays, I think you could make a solid argument of "Who the hell cares?", but in my mind, we have been editing text with full screen editors since the 80s, and had interactive IDEs since the 90s. If we could do this efficiently since the 90's, why should we opt for an inefficient solution now, especially if the efficient solutions are competitive?
Again, I'm saying this out of love. I use VS Code or Atom occasionally when I want to edit Markdown or HTML, and I think they are solid editors, especially considering that they are free. I understand that they are there to more to offer an open source and competitive solution to something like Sublime Text, and not to win-over the command-line-editor crowd, and at that I think they succeed. I just wish that an efficient framework like Qt, which has JS support, had caught on instead, since I think it would be a lot more efficient.
(I don't know if that is a great vision, but it is a good rationale to use Web tech for IDE development)
How low have we fallen from what programmers were concerned with memory use, and speed, and the right tool for the right job, and so on, and even Emacs was considered bloated...
Besides, they're still writing in a typed "language" (ts), so it's not like the dynamic language nature of JS that allows the VSCode base code to be developed incredibly quickly.
What really allows them to develop it incredibly quickly is the plugin API -- which allows tons of npm stuff to be ported and tons of JS programmers to create plugins for VS Code. A native statically typed based core would allow for that too. In fact the VSCode team already have moved some VSCode processing to C++ libs exactly for speed (and of course node itself is C++).
Using DOM for the drawing is faster (for a convenience perspective, not execution speed) yes, but with MS resources they could have made a streamlined equivalent that's much faster, more memory efficient, and doesn't have all the baggage of a web rendering engine. In fact, they have several native alternatives lying around they could make cross platform.
As it is, VSCode will ever have the burden of rendering to the DOM.
No, but it would "just be" an open source, MS backed, version of Sublime or TextMate. The concept of Visual Studio is different.
>We would get updates once a year instead of once a month.
The language the core is in is irrelevant as to whenever we would see updates. That's a concern of the release process.
>There are less C++ devs than JS devs.
Not really important, as most of the contributors are MS guys anyway. In fact a single person has made Sublime Text, an editor that offers most of what VSCode offers, with 1/100 the budget and manpower. If only it was Open Source too, or had a few more devs...
For what it's worth, the Visual Studio team now releases minor updates roughly every six weeks (including bug fixes and new features), and service updates almost weekly [1]. They also rely quite heavily on user feature requests [2].
[1] https://docs.microsoft.com/en-us/visualstudio/productinfo/vs...
[2] https://visualstudio.uservoice.com/forums/121579-visual-stud...