Familiar Column Selection in Visual Studio Code

Illustration

If you ever dealt with any advanced text editor, you are probably aware of column (a.k.a. block selection). You press Shift+Alt and then either use mouse or arrow keys to have a bit unusual block selection. While not needed often, it’s invaluable when it comes to dealing with text in columns.

Visual Studio Code does support it but, of course, there are minor issues. First of all, unlike almost any other editor (including Visual Studio!), shortcut is actually Shift+Ctrl+Alt. Fortunately this can be fixed either by manually remapping key bindings for column selection or by simply installing Visual Studio Keymap extension.

While that sorts out column selection key shortcut, it still leaves one annoying problem - if you move cursor in any direction while multiple lines are selected, you will see multiple cursors move - instead of more usual selection cancellation. Fortunately, you can add a few key bindings in keybindings.json to deal with that issue:

[
    {
        "key": "left",
        "command": "cancelSelection",
        "when": "editorHasMultipleSelections && textInputFocus"
    },
    {
        "key": "right",
        "command": "cancelSelection",
        "when": "editorHasMultipleSelections && textInputFocus"
    },
    {
        "key": "up",
        "command": "cancelSelection",
        "when": "editorHasMultipleSelections && textInputFocus"
    },
    {
        "key": "down",
        "command": "cancelSelection",
        "when": "editorHasMultipleSelections && textInputFocus"
    },
    {
        "key": "pageup",
        "command": "cancelSelection",
        "when": "editorHasMultipleSelections && textInputFocus"
    },
    {
        "key": "pagedown",
        "command": "cancelSelection",
        "when": "editorHasMultipleSelections && textInputFocus"
    }
]

Now you can enjoy block selection that works properly. :)

DRM Exceptions

A few days ago The Library of Congress has published Exemption to Prohibition on Circumvention of Copyright Protection Systems for Access Control Technologies. To make a long document short, you get to bypass a bit of DMCA (Digital Millennium Copyright Act) rules.

Most of the media talk about playing older games and fixing consoles or jail-breaking your phone but that’s not the full scope. For example, there is a security research exception. Without this exception any company ending as butt of a joke could sue the security researcher. And, the way how DMCA was written, they would prevail. Mind you, they still get to sue you, but now their victory is unlikely.

For Nth year in row, these rules also plug a hole in e-book accessibility. For example, without this exception, blind people would depend on the mercy of DRM-protected content producers. With this exception, they can use software of their choice to help them read and, if software has to break DRM to do it, so be it.

Lastly, one important category is fixing your vehicles. Quite a few manufacturers (John Deer comes first to mind but they are not alone) have been using DRM as a way to prevent you from fixing your vehicle yourself. There is quite a lot of revenue to get if you can block those pesky independent repairmen. Well, at least now they cannot use DRM to do this.

However, it’s not all good news as these provisions expire every three years and thus there is always a possibility of “LoC giveth, LoC taketh away” situation in the future. And just having right to DRM circumvention doesn’t mean shit if you still cannot get replacement parts and/or any replacement parts you do obtain are potentially seized.

But it is a good step forward.

Checking XigmaNAS Network Speed

If your XigmaNAS server is a bit slow, it’s often beneficial to see what is your network speed before changing settings - especially if you are on wireless. If your network cannot handle more than 50 Mbps, you cannot complain when you have only 5 MB/s Samba transfer rate.

While there are many ways you can check the speed, I usually find iperf3 the best choice. Not only it comes preinstalled on XigmaNAS, but you can also download precompiled binaries for Windows, Linux, and BSD to start with. If that’s not enough, you can always use freely available source and compile it yourself.

My approach is first starting server on XigmaNAS (or FreeNAS if that’s your NAS platform of choice):

iperf3 -s

Once server is listening I run the following commands on client, giving it IP address of that server:

iperf3 -c ^^192.168.0.1^^

And that’s it. This command will send data for 10 seconds toward server and receive back the same from it.

Armed with the number you can now deal with that pesky SMB3 performance.

Displaying EOL Symbol in Visual Studio Code

inline right

As soon as I started playing with Visual Studio Code a bit more, I found it’s whitespace rendering function lacking. While it does render spaces and tabs, I found it hard to deal with the absence of EOL marking. Yes, Visual Studio Code does show that information in status line and the whole thing is not really per line setting as Code will “normalize” line endings upon load but I simply missed those buggers.

I did find a couple extensions doing it but none really worked seamlessly as I wanted them. For one, they had a separate setting for turning them on/off. While I do love my EOL characters, I don’t want to see them all the time and I definitely don’t want to go into settings to change their state when there’s perfectly good Toggle Render Whitespace menu option available. Moreover, I wanted color of EOL to fit with the existing whitespace theme rendering instead configuring it separately.

I guess it was time to make my own extension.

Well, first, there is a really good guide through building simple extension. While it might not go deep into the topic, you will have both working extension and knowledge how to debug it by the time you’re done.

Secondly, if you go into %USERPROFILE%\.vscode\extensions directory (on Windows), you will see all extensions there - including their source code. I might not be the biggest fan of JavaScript (or TypeScript) but I am definitely the fan of learning by example. If you see some other extension doing something really close to what you need, you can see how it’s working and start from there.

Lastly, publishing extension is easy too. Assuming you got your package setup correctly, you’re just a few lines away from having it in the wild world.

To sum it up, creating and publishing extension was rather interesting and easy experiment. While JavaScript and occasionally flaky documentation did cause me to spend way too much time on this, it wasn’t all too bad. Debugging experience is acceptable and it feels nice to actually make something you’ll use. Not sure I’ll repeat it any time soon but I will definitely keep it in mind.

If it sounds interesting, you can install extension from within Visual Studio Code if you search for Render CRLF, check it’s marketplace page, or take a look at the source code.

RoboCopy Bandwidth Limitting

If you are using RoboCopy to make backups, you might have noticed it’s a bandwidth hog. Once you start copying, it will saturate the network making it a bit annoying to copy anything else at the same time.

While RoboCopy has no understanding of bandwidth limiting, there is a concept of inter-packet gap pause. Yes, you can go and calculate it (with a varying degree of success) or you can just test a few runs with different IPG number.

I personally found that /IPG:7 works wonderfully for my background backups.