Skip to content

Instantly share code, notes, and snippets.

@romainl
Last active October 8, 2025 13:24
Show Gist options
  • Save romainl/3e0cb99343c72d04e9bc10f6d76ebbef to your computer and use it in GitHub Desktop.
Save romainl/3e0cb99343c72d04e9bc10f6d76ebbef to your computer and use it in GitHub Desktop.

Revisions

  1. romainl revised this gist Oct 8, 2025. 2 changed files with 7 additions and 2 deletions.
    8 changes: 6 additions & 2 deletions automatic_file_marks.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # 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.
    File marks are like regular marks except that they are associated with 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:

    @@ -16,4 +16,8 @@ This is very handy in long sessions where you edit lots of filetypes.

    ---

    This was initially ***VERY*** influenced by another one I found online, circa 2011-12. I didn't bookmark it at the time, though. I have posted my own version in various forums over the years but I could never point people to the actual original and give credit where credit is due. If you know where to find it I would gladly link to it.
    This was initially ***VERY*** influenced by another one I found online, circa 2011-12. I didn't bookmark it at the time, though. I have posted my own version in various forums over the years but I could never point people to the actual original and give credit where credit is due. If you know where to find it I would gladly link to it.

    ---

    [My Vim-related gists](https://gist.github.com/romainl/4b9f139d2a8694612b924322de1025ce).
    1 change: 1 addition & 0 deletions automatic_file_marks.vim
    Original file line number Diff line number Diff line change
    @@ -7,4 +7,5 @@ augroup AutomaticMarks
    autocmd BufLeave *.yml,*.yaml normal! mY
    autocmd BufLeave .env* normal! mE
    autocmd BufLeave *.md normal! mM
    " add your own!
    augroup END
  2. romainl revised this gist Apr 28, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion automatic_file_marks.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    # Automatic file marks

    File marks are like regular marks except that they are associated to a specific *file*, which make them pretty useful for quick file navigation. One use taht 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.
    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:

  3. romainl revised this gist Apr 2, 2023. 2 changed files with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions automatic_marks.md → automatic_file_marks.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    # Automatic file marks

    File marks are like regular marks except that they are associated to a specific *file*, which make them pretty useful for quick file navigation. One use taht 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:
    File renamed without changes.
  4. romainl created this gist Apr 2, 2023.
    17 changes: 17 additions & 0 deletions automatic_marks.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,17 @@
    File marks are like regular marks except that they are associated to a specific *file*, which make them pretty useful for quick file navigation. One use taht 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.

    which makes it super easy to jump back to the last file of a certain kind that was edited:

    'E

    This is very handy in long sessions where you edit lots of filetypes.

    ---

    This was initially ***VERY*** influenced by another one I found online, circa 2011-12. I didn't bookmark it at the time, though. I have posted my own version in various forums over the years but I could never point people to the actual original and give credit where credit is due. If you know where to find it I would gladly link to it.
    10 changes: 10 additions & 0 deletions automatic_marks.vim
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,10 @@
    augroup AutomaticMarks
    autocmd!
    autocmd BufLeave *.css,*.scss normal! mC
    autocmd BufLeave *.html normal! mH
    autocmd BufLeave *.js,*.ts normal! mJ
    autocmd BufLeave *.vue normal! mV
    autocmd BufLeave *.yml,*.yaml normal! mY
    autocmd BufLeave .env* normal! mE
    autocmd BufLeave *.md normal! mM
    augroup END