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 / vanilla-surround.md
Last active November 13, 2024 17:53
Poor man's Surround

Poor man's Surround

The following shows how to replicate some of Surround's features if you don't happen to have it installed.

NOTE: We only dealt with the simplest cases, here, and the convoluted nature of some of these commands shows how well designed and useful that plugin is. And let's not talk about all the corner cases it handles.

Install it, it's worth it.

The list

@romainl
romainl / automatic_file_marks.md
Last active January 10, 2024 18:02
Automatic file marks

Automatic file marks

File marks are like regular marks except that they are associated to a specific file, which makes them pretty useful for quick file navigation. One use that is commonly mentionned would be to add a V mark to one's vimrc, for example, which would make editing it only one 'V away.

Here, a mnemonic mark is left when leaving files of a specific kind:

  • mark C for "CSS" and "SCSS",
  • mark H for "HTML",
  • etc.
@romainl
romainl / command-mode.md
Last active September 23, 2022 08:14
Words have a meaning

Command mode

@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.

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

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

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 August 6, 2024 12:32
git-jump hack that can be used FROM Vim
#!/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 November 4, 2024 04:33
Don't use Vim for the wrong reasons

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

: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 October 6, 2024 00:44
Off the beaten path

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,