Showing posts with label Tip. Show all posts
Showing posts with label Tip. Show all posts

Wednesday, November 30, 2016

Pasting a remote file into your local clipboard (* mouse not required)

So, I'm updating a configuration file on a remote server (using MobaXterm), and I need to copy the contents into some Trello documentation running in a browser on my local Windows machine.

The old fashioned way to do it is to select it with the mouse (which MobaXterm interprets as copying to my Windows clipboard), then Shift+Insert it into the browser. Well, turns out you can use the command line:

[Bishop@Cygwin]$ ssh user@host "< /path/to/file" | clip

On Windows, clip is a program to read from standard in and put into the Windows clipboard. On Mac OSX, replace clip with pbcopy for the same effect.

You could extend this approach: instead returning the whole file, return the result of a pipe line. Neat. Like magic, no more mouse needed.

Thursday, February 18, 2016

Big list of files to edit? vim to the rescue (again)

Did you know that you can treat the text under the cursor as a filename, and open that up for editing right in vim? Here's how:

  • gf will open the filename under the cursor in the current window
  • ^Wf will open it in a split window
  • ^Wgf will open it in a new window

Thursday, January 28, 2016

Vim gem: built-in calculation

Vim is my go-to editor. Has been for 20 years. Besides being an all-around awesome editor for composing text, it also has some handy built-ins, like calculations:

  • In insert mode, ^R= accepts a mathematical expression, the result of which will be inserted in place.
  • In normal mode, ^A increments the number at (or to the right of) the cursor by one, while ^X decrements it by one. These accept repeats, so 5^A will add 5 to the number.

Tuesday, January 13, 2015