Skip to content

Instantly share code, notes, and snippets.

View Matt-Deacalion's full-sized avatar
🏹
Ready, Fire, Aim!

Matt Matt-Deacalion

🏹
Ready, Fire, Aim!
  • Budapest, Hungary
View GitHub Profile
@romainl
romainl / nonemptylines.vim
Created September 23, 2017 13:59
Fun with non-empty lines
" jump to next non-empty line
nnoremap <key> :<C-u>call search('^.\+')<CR>
" jump to previous non-empty line
nnoremap <otherkey> :<C-u>call search('^.\+', 'b')<CR>
" extend visual selection to next non-empty line
xnoremap <key> :<C-u>k`\|call search('^.\+')\|normal! <C-r>=visualmode()<CR>``o<CR>
" extend visual selection to previous non-empty line
@romainl
romainl / countrepeat.md
Last active November 9, 2024 21:02
Repeat last edit n times

Repeat last edit n times

Did you ever wish you could repeat the last edit an arbitrary number of times without mashing the . key?

Well now you can.

Before

......
@romainl
romainl / headings.vim
Created September 23, 2017 13:50
Markdown : jump to next heading
" markdown : jump to next heading
function! s:JumpToNextHeading(direction, count)
let col = col(".")
silent execute a:direction == "up" ? '?^#' : '/^#'
if a:count > 1
silent execute "normal! " . repeat("n", a:direction == "up" && col != 1 ? a:count : a:count - 1)
endif
@romainl
romainl / vanilla-linter.md
Last active April 20, 2025 07:00
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 / autocommands.md
Last active November 9, 2024 21:04
Dealing with autocommands

Dealing with autocommands

Anatomy of a minimal autocommand

autocmd BufNewFile,BufRead *.foo set filetype=html
  • BufNewFile,BufRead is the list of events that trigger this autocommand.
  • *.foo is the pattern we want to match against the data returned by the event.
  • set filetype=html is the command we want to execute when the pattern matches the data returned by the event.
@htuscher
htuscher / .gitlab-ci.yml
Created August 3, 2017 08:12
Deploying with docker-compose via SSH tunnel in Gitlab CI
deploy:live:
image: 1drop/docker:git
stage: deploy
when: manual
environment:
name: production
url: https://www.somecustomer.de
before_script:
- eval $(ssh-agent -s)
- ssh-add <(echo "$SSH_PRIVATE_KEY")
@romainl
romainl / colorscheme-override.md
Last active March 8, 2025 21:23
The right way to override any highlighting if you don't want to edit the colorscheme file directly

The right way to override any highlighting if you don't want to edit the colorscheme file directly

Generalities first

Suppose you have weird taste and you absolutely want:

  • your visual selection to always have a green background and black foreground,
  • your active statusline to always have a white background and red foreground,
  • your very own deep blue background.
@romainl
romainl / ccr.vim
Last active November 9, 2024 21:06
Make various list-like commands more intuitive
" Background here: https://gist.github.com/romainl/047aca21e338df7ccf771f96858edb86
" with help from https://github.com/teoljungberg
function! CCR()
let cmdline = getcmdline()
let filter_stub = '\v\C^((filt|filte|filter) .+ )*'
command! -bar Z silent set more|delcommand Z
if getcmdtype() !~ ':'
return "\<CR>"
endif
@koistya
koistya / Sample Docker Web Application.md
Last active July 15, 2022 01:00
Sample Docker-based web application setup

Docker-based Web Application Setup (example)

This is an example of hosting standalone web front-end (web) and data API (api) applications under the same domain via Nginx (acting as a reverse proxy) and Docker, where HTTP requests starting with example.com/graphql and example.com/login/* are being redirected to http://api:3000 and everything else under the same domain is going to be passed to http://web:3000.

Folder Structure

.
├── /nginx.sites/               # Server configuration for each of web apps
├── /nginx.snippets/            # Nginx code snippets