-
Uses native vim regexes (which are slightly different from the regexes used by grep, ack, ag, etc) so the patterns are the same as with vim's within-file search patterns.
You can do a normal within-file search first, then re-use the same pattern to
const MINUTE = 60, | |
HOUR = MINUTE * 60, | |
DAY = HOUR * 24, | |
YEAR = DAY * 365; | |
function getTimeAgo(date) { | |
const secondsAgo = Math.round((+new Date() - date) / 1000); | |
if (secondsAgo < MINUTE) { | |
return secondsAgo + "s"; |
Uses native vim regexes (which are slightly different from the regexes used by grep, ack, ag, etc) so the patterns are the same as with vim's within-file search patterns.
You can do a normal within-file search first, then re-use the same pattern to
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.
" Add this to your vimrc to get a minimalist autocomplete pop | |
" Or use as a plugin : https://github.com/maxboisvert/vim-simple-complete | |
" Minimalist-TabComplete-Plugin | |
inoremap <expr> <Tab> TabComplete() | |
fun! TabComplete() | |
if getline('.')[col('.') - 2] =~ '\K' || pumvisible() | |
return "\<C-P>" | |
else |
<?php | |
// DEFINE our cipher | |
define('AES_256_CBC', 'aes-256-cbc'); | |
// Generate a 256-bit encryption key | |
// This should be stored somewhere instead of recreating it each time | |
$encryption_key = openssl_random_pseudo_bytes(32); | |
// Generate an initialization vector | |
// This *MUST* be available for decryption as well |