Skip to content

Instantly share code, notes, and snippets.

View DanSM-5's full-sized avatar

Eduardo D Sanchez DanSM-5

View GitHub Profile
@DanSM-5
DanSM-5 / get_selected_text.lua
Last active February 28, 2025 02:08
Function to get the text from the visual selection in the vim editor. Vimscript version is compatible in both vim and neovim. Also lua only version.
-- Function to get the selected text.
-- It handles when current mode is visual mode and when visual mode has ended.
-- It handle visual, visual line and visual block modes
-- The return is a list with the selected text per line from top to bottom and from left to right.
--
-- Based on the answers in the stackoverflow post:
-- https://stackoverflow.com/questions/1533565/how-to-get-visually-selected-text-in-vimscript/28398359
--
-- It has great answers but none quite behave as I expected, so this is my take on it.
@DanSM-5
DanSM-5 / emoji.txt
Last active November 13, 2024 04:15 — forked from keidarcy/emoji.txt
Plain Github emoji list
πŸ˜„ :smile:
πŸ˜† :laughing:
😊 :blush:
πŸ˜ƒ :smiley:
☺️ :relaxed:
😏 :smirk:
😍 :heart_eyes:
😘 :kissing_heart:
😚 :kissing_closed_eyes:
😳 :flushed:
@DanSM-5
DanSM-5 / edit-prompt-in-editor.ps1
Last active March 5, 2025 03:59
Edit current command in editor like bash C-x C-e (ctrl-x ctrl-e) for bash, zsh and powershell
# For windows powershell and pwsh
Set-PSReadLineKeyHandler -Chord 'ctrl+o,ctrl+e' -ScriptBlock {
$line = $cursor = $proc = $null
$editorArgs = @()
# Change this as you prefer
$editor = if ($env:EDITOR) { $env:EDITOR }
else { 'vim' }
try {
$tmpf = New-TemporaryFile