Skip to content

Instantly share code, notes, and snippets.

@romainl
romainl / showdeclaration.md
Last active January 22, 2023 14:54
Print declaration of word under the cursor

asciicast

@weilbith
weilbith / autoload_utils_location.vim
Last active July 26, 2019 22:50
Vim - Dynamic Location Lists
" Cache a possibly filled location list for a hiding buffer.
" Check if there is a non-empty list for the current buffer.
" Stores the list to the cache and empty the original one.
" The location window will be closed.
"
" Arguments:
" buffer - buffer to create the cache for
"
function! utils#location#cache_location_list(buffer) abort
if get(g:, 'dynamic_location_list_disable', v:false) | return | endif
@fnky
fnky / ANSI.md
Last active April 14, 2025 18:20
ANSI Escape Codes

ANSI Escape Sequences

Standard escape codes are prefixed with Escape:

  • Ctrl-Key: ^[
  • Octal: \033
  • Unicode: \u001b
  • Hexadecimal: \x1B
  • Decimal: 27
@adscriven
adscriven / findfile.vim
Last active September 13, 2020 01:08
Interactive file search (Vim)
" Way out of date now ...
" findfile.vim -- interactive file search
" Experimental; caveat emptor.
" Documentation is at the end.
" Public Domain.
let s:cpo = &cpo
set cpo&vim
@droustchev
droustchev / _README.md
Last active April 8, 2021 21:55
tmux vim navigation

I recently tried out the fantastic vim-tmux-navigator tmux plugin. Unfortunately, some the default key bindings conflict with some of the key bindings my fuzzy finder of choice uses. I wanted to remap them to the default vim split navigation commands that are prefixed with C-w, and found the solution of hjdivad in his gist. However, I wanted a simpler solution, so after some more digging I stumbled upon this reddit post and ultimately came up with the following solution, which doesn't rely on key bindings that unbind themselves, but uses tmux's 'key-tables'.

@ipan
ipan / diff-jq.md
Created January 16, 2018 04:47
compare two JSONs with jq #json #jq
@mbinna
mbinna / effective_modern_cmake.md
Last active April 12, 2025 02:22
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@yegappan
yegappan / gist:3b50ec9ea86ad4511d3a213ee39f1ee0
Last active April 11, 2023 00:03
Updating a quickfix/location list asynchronously without interfering with another plugin
Vim has many plugins (vim-go, ale, etc.) that use the quickfix/location list
feature. Some of these plugins process the output of an external command and
update the quickfix list asynchronously as the output becomes available.
Updating a quickfix or location list asynchronously opens up the possibility
that two or more plugins may try to update the same quickfix list with
different output. Also when a plugin is updating a quickfix list in the
background, the user may issue a command that creates or updates a quickfix
list. The plugin may then incorrectly use this new list to add the entries.
@romainl
romainl / vanilla-linter.md
Last active March 28, 2025 09:20
Linting your code, the vanilla way

Linting your code, the vanilla way

You may want a linter plugin to lint your code in Vim but you probably don't need it. At least try the built-in way before jumping on the plugin bandwagon.

Defining makeprg

autocmd FileType <filetype> setlocal makeprg=<external command>

This autocommand tells Vim to use <external command> when invoking :make % in a <filetype> buffer. You can add as many similar lines as needed for other languages.

@romainl
romainl / curentline.md
Last active March 19, 2023 07:27
Insert the current line into the command-line

Insert the current line into the command-line

This is an intuitive command-line mode mapping to insert the current line.

It is no longer needed since 8.0.1787 because the feature is now built-in. See :help c_ctrl-r_ctrl-l.


My Vim-related gists.