Aug 26, 2020

Change Directory in Vim

You can always use :cd to change the working directory for vim. Sometimes you simply want to change the directory to the one where the file that corresponds to the active buffer is in. You can do this by using :cd %:p:h. So, what does this mean? Well % I believe means the path of the current file. Then we first use the modifier :p which makes it the full path, and :h which removes the last part together with the separator of the path.

Code of the Day

test('overlap should return true when polygons overlap', () => {
  expect(polygon(
    [
      [0, 0],
      [2, 0],
      [2, 1],
      [0, 1],
    ]).overlap(
    polygon([
      [1, 0],
      [3, 0],
      [3, 1],
      [1, 1],
    ]))).toBeTruthy();
});

I'm working on overlapping of polygons. This is something that the game developers of course have really nice solutions for. The first solutions of that sort that I have found holds true only for convex polygons though, so I'm making my attempt on a solution myself. Time will tell if that's successful or not :)