Skip to content

Instantly share code, notes, and snippets.

Avatar
💰
Alwayz Into Somethin'

Romain Lafourcade romainl

💰
Alwayz Into Somethin'
  • Razorfish France
  • Paris, France
View GitHub Profile
@romainl
romainl / command-mode.md
Last active September 23, 2022 08:14
Words have a meaning
@romainl
romainl / field_notes.md
Last active April 9, 2022 11:00
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 / jest-and-vim.md
Created August 20, 2020 13:13
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 April 5, 2022 18:45
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 March 15, 2023 11:23
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 January 31, 2023 18:56
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 June 21, 2022 07:43
: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 February 5, 2023 13:21
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 January 28, 2023 05:23
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

@romainl
romainl / sum-operator.vim
Created January 26, 2020 18:18
Sum operator
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