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 / eslint-standard.md
Last active June 5, 2023 00:46
Painless ESLint/Standard integration

Painless ESLint/Standard integration

Our goal, here, is threefold:

  • use Vim's built-in features to their fullest,
  • be a good project citizen even if we don't use $EDITOR_DU_JOUR,
  • have a minimal but beneficial impact on the infrastructure of the project we work on.

Expose a simple interface for linting at the project level

@romainl
romainl / sum-operator.vim
Created January 26, 2020 18:18
Sum operator
" Print the sum of the lines covered by visual selection or motion
function! Sum(type, ...)
let sel_save = &selection
let &selection = "inclusive"
let reg_save = @@
*t'>
'[,']!awk '{ sum += $0 } END { print sum }'
let &selection = sel_save
@romainl
romainl / gt.vim
Created January 19, 2020 13:52
Slightly more intuitive gt/gT (may need some unlearning to get used to)
nnoremap <expr> gt ":tabnext +" . v:count1 . '<CR>'
nnoremap <expr> gT ":tabnext -" . v:count1 . '<CR>'
@romainl
romainl / global.md
Last active January 26, 2024 10:36
Quickfix alternative to :g/foo/#

Quickfix alternative to :g/foo/#

:help :global is an incredibly cool command.

One thing I like to do with :global is to list lines matching a given pattern in the current file and use that to move around. It looks like this:

:g/let/#
 7         let &path .= 'src/**,public/**,static/**'
 31     unlet b:gqview

33 nmap GQ :let b:gqview = winsaveview():set opfunc=Formatg@

@romainl
romainl / all-versions.txt
Last active June 21, 2020 06:02
Vim contributors (probably needs cleanup)
A.Politz
Aaron Burrow
Adam Slater
Adnan Zafar
Adri Verhoef
Adrian Kocis
Adrien Beau
Agathoklis Hatzimanikas
Agorgianitis Loukas
Ajit Thakkar
@romainl
romainl / vimrc
Last active September 8, 2022 06:09
One way to set up MacVim for Python and Python 3 on MacOS (assuming Python and Python 3 were installed through MacPorts)
if toupper(substitute(system('uname'), '\n', '', '')) =~ 'DARWIN'
\ && exists('+pythonhome')
\ && exists('+pythondll')
\ && exists('+pythonthreehome')
\ && exists('+pythonthreedll')
let python_path = '/opt/local/Library/Frameworks/Python.framework/Versions'
let &pythonhome = ''
let &pythondll = ''
let &pythonthreehome = ''
let &pythonthreedll = ''
@romainl
romainl / ctagsd
Last active March 14, 2024 14:05
Run ctags upon file change/addition/deletion in a Git repository
#!/usr/bin/env sh
# Requirements:
# git: https://git-scm.com/downloads
# entr: http://eradman.com/entrproject/
# ctags: http://ctags.sourceforge.net/ (Exuberant Ctags) or https://ctags.io/ (Universal Ctags)
# Usage:
# $ cd my_project
# $ ctagsd
@romainl
romainl / substitute-operator.vim
Last active August 4, 2023 07:46
Substitute operator
function! Substitute(type, ...)
let cur = getpos("''")
call cursor(cur[1], cur[2])
let cword = expand('<cword>')
execute "'[,']s/" . cword . "/" . input(cword . '/')
call cursor(cur[1], cur[2])
endfunction
nmap <silent> <key> m':set opfunc=Substitute<CR>g@
" Usage:
@romainl
romainl / typescript.md
Last active June 2, 2020 09:20
TypeScript ftplugin

TypeScript ftplugin

Attention! All this is a work in progress.

Include search

:help 'include' is set so that Vim recognizes both:

import Foo from 'foo';
@romainl
romainl / you
Last active August 4, 2019 17:11
#!/usr/bin/env bash
cd ~/Music/_dl
youtube-dl \
--extract-audio \
--audio-format mp3 \
--audio-quality 0 \
--embed-thumbnail \
--output '%(title)s.%(ext)s' \
"$1"