Skip to content

Instantly share code, notes, and snippets.

Avatar
💰
Alwayz Into Somethin'

Romain Lafourcade romainl

💰
Alwayz Into Somethin'
  • Publicis Sapient France
  • Paris, France
View GitHub Profile
@romainl
romainl / field_notes.md
Last active May 27, 2021
Quelques notes prises au fur et mesure de mon apprentissage, de fin 2009 à fin 2011.
View field_notes.md

1

Déplacer le curseur

H : en haut de l’écran

M : au milieu de l’écran

L : en bas de l’écran

@romainl
romainl / after#ftplugin#javascript.vim
Last active May 10, 2021
Set proper &path for Next.js and Nuxt.js
View after#ftplugin#javascript.vim
autocmd BufNewFile,BufRead * call <SID>DetectFrontEndFramework()
function! s:DetectFrontEndFramework()
if v:version >= 801 && has('patch1803')
let package_json = findfile('package.json', '.;')
if len(package_json)
let dependencies = readfile(package_json)
\ ->join()
\ ->json_decode()
@romainl
romainl / jest-and-vim.md
Created Aug 20, 2020
Jest and built-in Vim features
View jest-and-vim.md

Jest and built-in Vim features

Set up a sandbox

$ cd /tmp
$ mkdir jest-and-vim
$ cd $_
$ npm init -y
$ npm install --save-dev jest
@romainl
romainl / dotctags.md
Last active Aug 11, 2020
Extending Exuberant Ctags
View dotctags.md

Extending Exuberant Ctags

Configuration

Like most CLI programs, Ctags can have its behaviour changed by passing it options like -R, to make it work recursively, or -f badaboom, to make it generate a file called badaboom.

Teaching Ctags about a new language or extending the rules of a supported language is also done with options like --langmap or --regex-<lang>. For example, we could call Ctags with these options:

$ ctags -R --regex-javascript=<regex> --regex-javascript=<regex> [...] --regex-javascript=<regex> .
@romainl
romainl / git-jump
Last active Mar 20, 2021
git-jump hack that can be used FROM Vim
View git-jump
#!/bin/sh
usage() {
cat <<\EOF
usage: git jump <mode> [<args>]
Jump to interesting elements in an editor.
The <mode> parameter is one of:
diff: elements are diff hunks. Arguments are given to diff.
@romainl
romainl / Don't use Vim.md
Last active May 28, 2021
Don't use Vim for the wrong reasons
View Don't use Vim.md

Don't use Vim

Don't do the crime, if you can't do the time.

-- Anthony Vincenzo "Tony" Baretta

Vim is an amazing text editor. I love it. Really, I wouldn't [organize][organize] a Vim advent calendar if I didn't. But, as amazing as it is, Vim is not for everyone. It can't solve all your problems, or be a TUI version of your favorite IDE, or make you a better programmer, or land you that dream job in the Bay Area. But Vim can help you be more mindful, focused, and efficient, as long as you approach it with the right mindset.

Don't get me wrong, I certainly welcome you to try Vim, but I'm not a proselyte. I don't thrive on newbies. I just want you to use the right tool for the job and not waste your—and anyone's—time on a fruitless quest.

@romainl
romainl / diff.md
Last active Jul 31, 2020
:DiffOrig but smarter
View diff.md

:DiffOrig but smarter

This is an enhanced version of the snippet provided under :help diff-original-file.

Where the original :DiffOrig only shows differences between the buffer in memory and the file on disk, :Diff can be used in two ways:

  • against the file on disk, like the original, with:

    :Diff
    
@romainl
romainl / path.md
Last active May 27, 2021
Off the beaten path
View path.md

Off the beaten path

What is &path used for?

Vim uses :help 'path' to define the root directories from where to search non-recursively for files.

It is used for:

  • gf, gF, <C-w>f, <C-w>F, <C-w>gf, <C-w>gF,
  • :find, :sfind, :tabfind,
@romainl
romainl / eslint-standard.md
Last active Jan 25, 2021
Painless ESLint/Standard integration
View eslint-standard.md

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

View sum-operator.vim
" 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