Skip to content

Instantly share code, notes, and snippets.

Avatar

Andrew Radev AndrewRadev

View GitHub Profile
@AndrewRadev
AndrewRadev / eruby.vim
Created Jul 1, 2012
My ftplugin/eruby.vim file
View eruby.vim
" This file is supposed to be saved as "~/.vim/ftplugin/eruby.vim". If desired, parts of it can be
" picked and saved into separate files in the same directory as long as they start with "eruby_",
" for example "~/.vim/ftplugin/eruby_surroundings.vim".
" Surround mappings. The character defines the mapping. Most of these are meant for use in visual
" mode to add a wrapping, although they can probably be used otherwise as well.
"
" These ones let you wrap a piece of text on a line with erb <% %> markers. The last one is
" particularly useful for adding translations in the place of hardcoded strings.
"
@AndrewRadev
AndrewRadev / vim_guide.md
Created Apr 24, 2020
An old Vim guide I wrote in Bulgarian. Originally published at https://github.com/fmi/ruby-course-guides/blob/master/vim.md#readme
View vim_guide.md

Vim

TL;DR – VIM EMERGENCY!

  • За да излезете от Vim, без да запазвате файл, натиснете Esc, след това напишете :q! и натиснете Enter.
  • За да направите промяна, натиснете i и си редактирайте текста като в нормален редактор.
  • За да запазите направените промени, натиснете Esc и след това напишете :w и натиснете Enter. След това е окей да излезете от редактора с :q.

А ако се чудите къде да инвестирате следващите десет минути от живота си, непременно прочетете това ръководство до края.

@AndrewRadev
AndrewRadev / bookmarks.vim
Created Nov 16, 2011
Simple bookmark management in Vim
View bookmarks.vim
set viminfo+=!
if !exists('g:BOOKMARKS')
let g:BOOKMARKS = {}
endif
" Add the current [filename, cursor position] in g:BOOKMARKS under the given
" name
command! -nargs=1 Bookmark call s:Bookmark(<f-args>)
function! s:Bookmark(name)
@AndrewRadev
AndrewRadev / efactory.vim
Last active Apr 14, 2020
An `:Efactory` command for jumping to factory_bot definitions in rails projects
View efactory.vim
" Extracted from:
" https://github.com/AndrewRadev/Vimfiles/blob/0490041cf2d0e4f7a9b2e1361bb47971dd59d836/miniplugins/plugin/rails_extra.vim
"
" Installation:
"
" Copy file to ~/.vim/plugin/efactory.vim, or just paste the whole thing in
" your `.vimrc`. No guarantees it'll work well for you, seems to work for me.
" Will extract to a plugin at some point and it'll hopefully be more reliable.
"
" Usage:
@AndrewRadev
AndrewRadev / qf.vim
Created Dec 2, 2011
Delete lines from the quickfix window (with undo)
View qf.vim
" Place in ftplugin/qf.vim
xnoremap <buffer> d :DeleteLines<cr>
nnoremap <buffer> dd :DeleteLines<cr>
nnoremap <buffer> u :UndoDelete<cr>
if !exists(':DeleteLines')
let b:deletion_stack = []
" Delete by a pattern (with undo placing them all on top):
@AndrewRadev
AndrewRadev / ember-projections.json
Last active Oct 28, 2019
A `.projections.json` file that can be used with vim-projectionist for navigating ember.js projects
View ember-projections.json
{
"app/initializers/*.js": {
"type": "initializer"
},
"app/models/*.js": {
"type": "model",
"alternate": "app/adapters/{}.js",
},
"app/adapters/*.js": {
"type": "adapter",
@AndrewRadev
AndrewRadev / Makefile
Created Jan 8, 2012
Stupidly simple Makefile for working with an Arduino
View Makefile
ARDUINO_PATH='/usr/share/arduino/hardware/arduino/cores/arduino'
VARIANTS_PATH='/usr/share/arduino/hardware/arduino/variants/standard'
MCU='atmega328p'
F_CPU=16000000
PORT='/dev/ttyACM0'
UPLOAD_RATE=115200
CORE_SOURCES=\
$(ARDUINO_PATH)/wiring.c\
$(ARDUINO_PATH)/wiring_analog.c\
@AndrewRadev
AndrewRadev / main.rs
Last active Nov 13, 2018
Divide successfully or default to zero
View main.rs
trait OrZero {
fn or_zero(self) -> Self;
}
impl OrZero for f64 {
fn or_zero(self) -> Self {
if self.is_normal() { self } else { 0.0 }
}
}
@AndrewRadev
AndrewRadev / README.markdown
Created Aug 11, 2011 — forked from skanev/README.markdown
Convert a <select> with <optgroups> to two <select>s that are interconnected
View README.markdown

If you have a select with option groups:

<select data-nested-select="Select country">
  <option>Select city</option>
  <optgroup label="Bulgaria">
    <option value="sofia">Sofia</option>
    <option value="plovdiv">Plovdiv</option>
  </optgroup>
  <optgroup label="Sweden">
    <option value="stockholm">Stockholm</option>
@AndrewRadev
AndrewRadev / dsf.vim
Last active Nov 5, 2018
Delete surrounding function call
View dsf.vim
" Delete surrounding function call
" Relies on surround.vim
"
" function_call(cursor_here) => dsf => cursor_here
"
" Try `dsf` with more complicated structures:
"
" nested(function_call(cursor_here))
" nested(cursor_here(chewy_center))
" One::Two.new([cursor_here])
You can’t perform that action at this time.