Skip to content

Instantly share code, notes, and snippets.

View veirus's full-sized avatar

Alex veirus

View GitHub Profile
@veirus
veirus / autobrackets.vim
Created May 28, 2018 18:47
Simple function and mappings to close brackets automagically. In practice this shit is more irritating than helpful.
" Auto-insert closing parenthesis/brace {{{2
" TODO: make bracket insertion a little smarter
" right now it gets in the way more than it helps
inoremap ( ()<Left>
inoremap { {}<Left>
inoremap [ []<Left>
" Auto-delete closing parenthesis/brace
function! BetterBackSpace() abort
let cur_line = getline('.')
@veirus
veirus / dror_pathlib.py
Created June 7, 2018 01:15
My *favourite* sorting script now with **Pathlib**
#!/usr/bin/env python3.6
# -*- coding: utf-8 -*-
# dror - pathlib edition
# Based on https://gist.github.com/dansku/9040240#file-dropboxorganize-py
__lastchanged__ = '2018-06-07 06:07'
__verstion__ = '0.6.2'
from datetime import date
from pathlib import Path
@veirus
veirus / better_jk.vim
Last active June 27, 2018 15:44
Mappings for easier line navigation with <j> and <k> when `wrap` is on
" screen line scroll - very useful with wrap on
" https://bluz71.github.io/2017/05/15/vim-tips-tricks.html
nnoremap <expr> j v:count ? (v:count > 5 ? "m'" . v:count : '') . 'j' : 'gj'
nnoremap <expr> k v:count ? (v:count > 5 ? "m'" . v:count : '') . 'k' : 'gk'
@veirus
veirus / packages-vivid.vim
Last active October 8, 2018 13:32
Installing Vim plugins using `axvr/Vivid.vim`. Pros: less boilerplate than `minpac`; Cons: you need to enable plugins *manually* - may brake some of them.
" quick add plugins for a plugin manager to load {{{1
function! AddPacFromCb() abort
if v:version >= 801 || (v:version == 800 && has("patch1630"))
let l:cb = trim(@+)
else
" do oldschool way to trim all spaces and whatnot
let l:cb = substitute(@+,'\v^\s*(.{-})\s*\n$','\1','')
endif
let l:cb = substitute(l:cb, '\v^https://github.com/','','')
put = 'Plugin ''' . l:cb . ''''
@veirus
veirus / InsertFoldmarker.vim
Last active October 8, 2018 14:38
Quick and "smart" (not really...) insertion of current foldmarker + mostly accurate (not really...) foldlevel
function! InsertFoldMarker(...) abort
let l:cur_line = getline('.')
let l:markers = split(&l:fmr, ',')
let l:marker = (a:0) && len(l:markers)>1 ? l:markers[1] : l:markers[0]
let l:level = foldlevel('.')
let l:level = l:level == 0 ? '1' : l:level
let l:cms = split(&l:cms, '%s')
" TODO: handle paired comment markers
let l:cms = (a:0) && len(l:cms)>1 ? l:cms[1] : l:cms[0]
let l:marker_cnt = count(l:cur_line, l:cms)
var names = document.body.getElementsByClassName('gameListRowItemName');
var namesString = '';
for (var i = 0; i < names.length; i++) namesString += (names[i].innerText + '\n');
@veirus
veirus / md2org_URLS.vim
Last active July 30, 2018 14:04
Convert markdown style links to emacs orgmode format
" even easier with `.\{-}`:
%s/\[\(.\{-}\)](\(.\{-}\))/[[\2][\1]]/g
@veirus
veirus / .eslintrc.js
Created November 7, 2018 13:39 — forked from nkbt/.eslintrc.js
Strict ESLint config for React, ES6 (based on Airbnb Code style)
{
"env": {
"browser": true,
"node": true,
"es6": true
},
"plugins": ["react"],
"ecmaFeatures": {
from PIL import Image
import numpy as np
import matplotlib.pyplot as pyplot
import pandas as pd
from datetime import datetime
import seaborn as sns
ini = datetime.now()
fle = "Cosmonaut" # File name
" It's probably not exactly what you want, because you mentioned autocmds in the original post, but you may be interested in :h :DiffOrig. FWIW, here's a modified version of this custom command which I'm using:
com! -bar DiffOrig echo s:diff_orig()
fu! s:diff_orig() abort
let cole_save = &l:cole
setl cole=0
vnew
setl bh=wipe nobl bt=nofile noswf