Skip to content

Instantly share code, notes, and snippets.

@lassekongo83
lassekongo83 / restore-youtube-scrollbar.user.js
Last active July 10, 2023 07:02
Make YouTube use your browser's default scrollbar
// ==UserScript==
// @name Restore YouTube Scrollbar
// @namespace Violentmonkey Scripts
// @match https://www.youtube.com/*
// @grant none
// @version 1.0
// @author https://github.com/lassekongo83
// @description Make YouTube use your browser's default scrollbar
// ==/UserScript==
@FractalWire
FractalWire / nvrp
Last active September 5, 2020 03:32
preview file with fzf and nvr
#!/bin/bash
# simple script to preview files with the help of fzf
cwd=$(pwd)
# set up
nvr --nostart -cc 'let nvrp_buffer=""'
set_variables='mime_list=( "application/json" "text/" ); mime=$(file --mime-type {} | cut -d " " -f 2)'
f_is_text='for m in ${mime_list[@]}; do test "${mime#$m}" != "$mime" && break || false; done'
@romainl
romainl / grep.md
Last active April 28, 2024 19:53
Instant grep + quickfix

FOREWORDS

I don't mean the snippet at the bottom of this gist to be a generic plug-n-play solution to your search needs. It is very likely to not work for you or even break things, and it certainly is not as extensively tested and genericised as your regular third-party plugin.

My goal, here and in most of my posts, is to show how Vim's features can be leveraged to build your own high-level, low-maintenance, workflows without systematically jumping on the plugins bandwagon or twisting Vim's arm.


Instant grep + quickfix

@PeterRincker
PeterRincker / SortGroup.vim
Last active March 17, 2024 04:51
Sort groups of lines in vim
" :[range]SortGroup[!] [n|f|o|b|x] /{pattern}/
" e.g. :SortGroup /^header/
" e.g. :SortGroup n /^header/
" See :h :sort for details
function! s:sort_by_header(bang, pat) range
let pat = a:pat
let opts = ""
if pat =~ '^\s*[nfxbo]\s'
let opts = matchstr(pat, '^\s*\zs[nfxbo]')
@romainl
romainl / vanilla-linter.md
Last active April 13, 2024 03:30
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 / redir.md
Last active March 22, 2024 17:09
Redirect the output of a Vim or external command into a scratch buffer

Redirect the output of a Vim or external command into a scratch buffer

Usage (any shell)

Show full output of command :hi in scratch window:

:Redir hi

Show full output of command :!ls -al in scratch window:

@alexlee-gk
alexlee-gk / configure_cuda_p70.md
Last active March 19, 2024 17:47
Use integrated graphics for display and NVIDIA GPU for CUDA on Ubuntu 14.04

This was tested on a ThinkPad P70 laptop with an Intel integrated graphics and an NVIDIA GPU:

lspci | egrep 'VGA|3D'
00:02.0 VGA compatible controller: Intel Corporation Device 191b (rev 06)
01:00.0 VGA compatible controller: NVIDIA Corporation GM204GLM [Quadro M3000M] (rev a1)

A reason to use the integrated graphics for display is if installing the NVIDIA drivers causes the display to stop working properly. In my case, Ubuntu would get stuck in a login loop after installing the NVIDIA drivers. This happened regardless if I installed the drivers from the "Additional Drivers" tab in "System Settings" or the ppa:graphics-drivers/ppa in the command-line.

@ahmedelgabri
ahmedelgabri / statusline.vim
Last active September 13, 2022 13:15
Trying to build my vim statusline without plugins
" Statusline & Tabline/Buffer line
" Dynamically getting the fg/bg colors from the current colorscheme, returns hex which is enough for me to use in Neovim
" Needs to figure out how to return cterm values too
let fgcolor=synIDattr(synIDtrans(hlID("Normal")), "fg", "gui")
let bgcolor=synIDattr(synIDtrans(hlID("Normal")), "bg", "gui")
" Tabline/Buffer line
set showtabline=2
set tabline="%1T"
@wellle
wellle / yank.vim
Last active May 10, 2023 02:36
Yank without moving the cursor to the beginning of the yanked text
nnoremap <silent> y :<C-U>call MarkAndSetOpfunc()<CR>g@
vnoremap <silent> y :<C-U>call MarkYankAndJump()<CR>
function! MarkAndSetOpfunc()
let g:save_cursor = getpos(".")
set opfunc=YankAndJumpBack
endfunction
function! MarkYankAndJump()
let g:save_cursor = getpos(".")