Skip to content

Instantly share code, notes, and snippets.

Assuming you have followed all the steps to install / setup WSL2 -> https://docs.microsoft.com/en-us/windows/wsl/install-win10
**Tested on Ubuntu 20.04**
Step 1 - Find out default gateway and DNS servers
- Navigate to `Control Panel\Network and Internet\Network Connections`
- Right click on relevant connection type WiFi or Ethernet and select `Status`
- Status screen will be displayed, click on `Details` button
- Network Connection details screen will be displayed
- Note down `IPv4 default gateway` and `IPv4 DNS Servers` if available
@Gordin
Gordin / lid.sh
Created December 5, 2020 01:55
script, that moves windows to another monitor, when the lid of the notebook is closed. Run with `watch -n 0.5 ./lid.sh`
#!/usr/bin/env bash
LID_TMP='/tmp/lidscript.tmp'
# Read hoved windows from file
readarray moved_windows < $LID_TMP
# remove newlines after every element...
newMovedWindows=()
for i in "${!moved_windows[@]}"; do
without_newline=${moved_windows[$i]%$'\n'}
if [[ $without_newline != "" ]]; then
@romainl
romainl / path.md
Last active April 17, 2024 07:42
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,
@yegappan
yegappan / VimScriptForPythonDevelopers.MD
Last active January 12, 2024 10:51
Vim script for Python Developers

Vim Script for Python Developers

This is a guide to Vim Script development for Python developers. Sample code for the various expressions, statements, functions and programming constructs is shown in both Python and Vim Script. This is not intended to be a tutorial for developing Vim scripts. It is assumed that the reader is familiar with Python programming.

For an introduction to Vim Script development, refer to usr_41.txt, eval.txt and Learn Vimscript the Hard Way

For a guide similar to this one for JavaScript developers, refer to Vim Script for the JavaScripter

This guide only describes the programming constructs that are present in both Python and Vim. The constructs that are unique to Vim (e.g. autocommands, [key-mapping](https://vimhelp.org/map.txt.html#key-m

@romainl
romainl / ctagsd
Last active March 14, 2024 14:05
Run ctags upon file change/addition/deletion in a Git repository
#!/usr/bin/env sh
# Requirements:
# git: https://git-scm.com/downloads
# entr: http://eradman.com/entrproject/
# ctags: http://ctags.sourceforge.net/ (Exuberant Ctags) or https://ctags.io/ (Universal Ctags)
# Usage:
# $ cd my_project
# $ ctagsd

Vim will move the cursor to the beginning of an object after invoking operator upon it. From an interactive editing perspective this may be considered annoying however it is the consistent choice as operators can be destructive. As such restoring the cursor to its prior position after invoking an operator on an object may not make sense.

There are many ways possible to alter this behaviour to your preference with mappings and/or scripting. But with custom operator mappings this can be particularly ugly.

@jerdna-regeiz
jerdna-regeiz / togglesurround.vim
Created January 24, 2019 10:11
vim-surround toggling quotes
function! Toggle_Surround(char)
let pos = getcurpos()
let cur = col(".")
exe "norm! va".a:char
let start = col("v")
let end = col(".")
exe "norm! \<esc>"
call cursor(pos[1], pos[2])
if start <= cur && cur <= end && start != end
" inside quote :)
@yegappan
yegappan / VimDevelopmentProcess
Last active April 19, 2022 00:15
My development process for contributing to Vim
I use the below described development process and tools for developing Vim features.
I use a Ubuntu system for most of the development. But the tools mentioned below
are also available on MacOS.
1. Clone the Vim source code from https://github.com/vim/vim.git.
2. Modify src/Makefile to enable additional compiler diagnostics:
CFLAGS=-Wall -Wextra -pedantic
@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