Skip to content

Instantly share code, notes, and snippets.

View Sammyalhashe's full-sized avatar
🎯
Focusing

Sammyalhashe

🎯
Focusing
View GitHub Profile
@Sammyalhashe
Sammyalhashe / 09.cpp
Last active January 2, 2024 02:18
advent_of_code_day9_2022
#include <assert.h>
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
@Sammyalhashe
Sammyalhashe / folding.vim
Created October 3, 2020 20:47
Fancy folding in vim
function! NeatFoldText()
let line = ' ' . substitute(getline(v:foldstart), '^\s*"\?\s*\|\s*"\?\s*{{' . '{\d*\s*', '', 'g') . ' '
let lines_count = v:foldend - v:foldstart + 1
let lines_count_text = '| ' . printf("%10s", lines_count . ' lines') . ' |'
let foldchar = matchstr(&fillchars, 'fold:\zs.')
let foldtextstart = strpart('+' . repeat(foldchar, v:foldlevel*2) . line, 0, (winwidth(0)*2)/3)
let foldtextend = lines_count_text . repeat(foldchar, 8)
let foldtextlength = strlen(substitute(foldtextstart . foldtextend, '.', 'x', 'g')) + &foldcolumn
return foldtextstart . repeat(foldchar, winwidth(0)-foldtextlength) . foldtextend
endfunction