Skip to content

Instantly share code, notes, and snippets.

View romainl's full-sized avatar
💰
Alwayz Into Somethin'

Romain Lafourcade romainl

💰
Alwayz Into Somethin'
  • Razorfish France
  • Paris, France
View GitHub Profile
@romainl
romainl / gq.vim
Last active August 21, 2022 17:17
Formatting without moving
" gq wrapper that:
" - tries its best at keeping the cursor in place
" - tries to handle formatter errors
function! Format(type, ...)
normal! '[v']gq
if v:shell_error > 0
silent undo
redraw
echomsg 'formatprg "' . &formatprg . '" exited with status ' . v:shell_error
endif
@romainl
romainl / haskell_musings.txt
Created June 29, 2019 07:56
Haskell musings
https://haskell-miso.org/
a web framework inspired by Elm, uses GHCJS
http://blog.vmchale.com/article/haskell-frontend
a quick Miso tutorial
https://dc25.github.io/myBlog/2017/11/26/minesweepers-written-using-elm-reflex-miso.html
@romainl
romainl / blame.md
Last active March 19, 2023 07:26
Super cheap git blame

Super cheap git blame

git blame current line

:GB

git blame range

:7,13GB

:,+5GB

@romainl
romainl / grep.md
Last active April 28, 2024 19:53
Instant grep + quickfix

FOREWORDS

I don't mean the snippet at the bottom of this gist to be a generic plug-n-play solution to your search needs. It is very likely to not work for you or even break things, and it certainly is not as extensively tested and genericised as your regular third-party plugin.

My goal, here and in most of my posts, is to show how Vim's features can be leveraged to build your own high-level, low-maintenance, workflows without systematically jumping on the plugins bandwagon or twisting Vim's arm.


Instant grep + quickfix

@romainl
romainl / a.test.js
Last active January 18, 2020 09:19
What would be the simplest cross-environment JavaScript testing framework?
/*
Pros: - intuitive syntax
- portable
Cons: - always exits with 0, non-blocking
- legibility/alignment issues
*/
const testedFunction = (param) => {
return param * 2;
};
@romainl
romainl / showdeclaration.md
Last active January 22, 2023 14:54
Print declaration of word under the cursor

asciicast

@romainl
romainl / sort.vim
Created December 31, 2018 10:30
Sort operator
function! Sort(type, ...)
'[,']sort
endfunction
nmap <silent> <key> :set opfunc=Sort<CR>g@
" usage:
" <key>ip
" <key>G
@romainl
romainl / tags.md
Last active March 25, 2022 07:00
Tags

Tags

Setup

Tell Vim to look for tags files:

  • in the directory of the current file,
  • in the working directory,
  • and in every parent directory, recursively,
@romainl
romainl / https.md
Created August 9, 2018 19:19
HTTPS support in Express

Create path/to/cert.template

[req]
distinguished_name = req_distinguished_name
x509_extensions = v3_req
prompt = no
  [req_distinguished_name]
C = XX
ST = XX

L = XX

@romainl
romainl / multivide.vim
Last active September 17, 2023 10:11
Multiply/divide by [count]
function! Multivide(divide)
let cnt = v:count1
let old_reg = getreg("v")
call search('\d\([^0-9\.]\|$\)', 'cW')
normal v
call search('\(^\|[^0-9\.]\d\)', 'becW')
normal "vygv
if a:divide == 1
execute 'normal "_c' . @v / cnt
else