Skip to content

Instantly share code, notes, and snippets.

Avatar

Sérgio Luiz Araújo Silva voyeg3r

View GitHub Profile
@voyeg3r
voyeg3r / nvim_flash_cursorline.lua
Created Nov 6, 2021
Flash neovim cursorline (just for a second)
View nvim_flash_cursorline.lua
-- in your utils.lua
local M = {}
-- https://vi.stackexchange.com/questions/31206
M.flash_cursorline = function()
vim.opt.cursorline = true
vim.cmd([[hi CursorLine guifg=#000000 guibg=#ffffff]])
vim.fn.timer_start(200, function()
vim.cmd([[hi CursorLine guifg=NONE guibg=NONE]])
vim.opt.cursorline = false
View ultisnips_custom.vim
" File: ultisnips_custom.vim - Custom UltiSnips settings
" Maintainer: Sergio Araújo
" Oririnal Creator: Noah Frederick
" Last Change: abr 02 2019 17:24
" Place it at: after/plugin/ultisnips_custom.vim
"
" esse script está funcionando standalone
" ou seja sem interação com outros que não sejam
" os que já vem com o sistema e insere templates zsh, sh, python etc.
View togglecomment.vim
" Reference: https://stackoverflow.com/a/24652257/2571881
" TODO: Reselect visual mode
" OBS: I was using --> exec 'normal! _"_2x'
" How to know if I have the optional space after the comment '[ ]?' ?
" because this influences the cursor position
" Now all comments are added at the beginning of line because other people want
" to uncomment and comment using visual block
" after that I should give some suggestions to [mike](https://stackoverflow.com/users/2839380/mike) at stackoverflow
View togglecomment.vim
" source: https://stackoverflow.com/a/24046914/2571881
let s:comment_map = {
\ "c": '\/\/',
\ "cpp": '\/\/',
\ "go": '\/\/',
\ "java": '\/\/',
\ "javascript": '\/\/',
\ "lua": '--',
\ "scala": '\/\/',
\ "php": '\/\/',
View MoveEn.vim
" In this version, even if your paragraph does not have a preceding blank line
" it will performa the task, pleas comment on it.
function! MoveEm(position)
let saved_cursor = getpos(".")
"let previous_blank_line = search('^$', 'bn')
keepjumps execute 'normal {'
if getline('.') !~ '^$'
let previous_blank_line = line('.') - 1
else
View reverse-paragraphs.md

Reverse paragraphs order using [n]vim

Let's say you have a file with these lines and whant to reverse its paragraphs order. Using our belove [n]vim you can just execute

I have added the line numbers but you can ajust the numbers accordingly

1   \begin{rSubsection}{Example 1}{}{Redacted}{}
@voyeg3r
voyeg3r / copyandincrease.vim
Created Jan 28, 2018
This function creates a copy of any function increasing each number by one
View copyandincrease.vim
fun! CopyAndIncrease()
try
let l:old_copy = getreg('0')
normal yip
let @0 = substitute(@0,'\d\+','\=submatch(0) + 1','g')
exec "normal }O\<Esc>p"
finally
call setreg('0', l:old_copy)
endtry
endfun
View how-to-speeddating.txt
Pra quem não sabe o comando Ctrl-x decrementa números em modo
normal e o comando Ctrl-a incrementa, acontece que ele não reconhece
numeros complexos com segundos por exempo, o plugin speeddating resolve isso
veja como consertei minha legenda usando o vim com esse plugin
Minha legenda estava 187 segundos atrasada
O som começava aos 51 segundos e a primeira legenda estava:
View explanation-001.txt
getreg -> usado para pegar o valor de um registro
setreg -> usado para setar um registro
let @0 = substitute(@0,'\d\+','\=submatch(0) + 1','g') -> usado para incrementar os números do clipboard
normal yip ...... copia o bloco em modo normal
exec "normal }O\<Esc>p" -> cola o trecho incrementado abaixo do paragrafo atual
@voyeg3r
voyeg3r / CopyAndIncrease.vim
Last active Jan 28, 2018
this function increases each number in a copyied function or paragraph
View CopyAndIncrease.vim
fun! CopyAndIncrease()
try
let l:old_copy = getreg('0')
normal yip
let @0 = substitute(@0,'\d\+','\=submatch(0) + 1','g')
exec "normal }O\<Esc>p"
finally
call setreg('0', l:old_copy)
endtry
endfun