Skip to content

Instantly share code, notes, and snippets.

Andrew Radev AndrewRadev

Block or report user

Report or block AndrewRadev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@AndrewRadev
AndrewRadev / convert_dict.vim
Created Dec 28, 2016
Convert a python dict into a tuple of pairs
View convert_dict.vim
command! ConvertDict call s:ConvertDict()
function! s:ConvertDict()
" Save view for restoring later
let saved_view = winsaveview()
" If we're not in a dict, do nothing
if searchpair('{', '', '}', 'bcW', '', line('.')) <= 0
return
endif
View cfile.vim
" The filename used for the cfile
let s:cfile_filename = ''
" The last mtime of the filename
let s:cfile_mtime = -1
" Define a command that can be called like:
"
" Cfile errors.txt
"
" Apart from loading the error file in the quickfix window, it also
@AndrewRadev
AndrewRadev / custom_ember_gf.vim
Last active May 22, 2016
An example for a custom ember_tools gf callback
View custom_ember_gf.vim
" This is a project-specific Vim file that boosts ember_tools' gf mapping to
" follow translation keys to their yaml files.
let g:ember_tools_custom_gf_callbacks = [
\ 'EmberGfTranslations'
\ ]
function! EmberGfTranslations()
" only emblem files in this project
if &filetype != 'emblem'
View rails_gf_translation.vim
let g:rails_gf_callbacks = [
\ 'RailsGfTranslation'
\ ]
function! RailsGfTranslation()
let saved_iskeyword = &iskeyword
set iskeyword+=.
if !ember_tools#search#UnderCursor('\%(I18n\.\)\=t(\=[''"]\zs\k\+[''"]')
let &iskeyword = saved_iskeyword
@AndrewRadev
AndrewRadev / ember-projections.json
Last active Jun 20, 2018
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 / 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])
View phasors.rb
require 'rational'
require 'complex'
class Phasor
attr_reader :magnitude, :angle
class << self
def from_polar(magnitude, angle)
new(magnitude, angle)
end
View nerdtree_talk
- Standard netrw: https://twitter.com/PascalPrecht/status/489328558700249088
- vim-vinegar: https://github.com/tpope/vim-vinegar
- NERDTree: https://github.com/scrooloose/nerdtree
- Basic usage: navigating, opening a file, opening a directory
- What makes it good:
- powerful navigation
- filesystem manipulation
- customizations
View share-image.sh
#! /bin/sh
set -e
if [ -z $1 ];
then
echo "USAGE: share-image <image>"
exit 1
fi
View qfappend.vim
" If you've executed a grep/ack command and you have a bunch of stuff in your
" quickfix window, but want to add another grep to it, this could help:
"
" :Ack ProjectCollaborator
" :Qfappend Ack UserCollaborator
"
" This will add the new search results to the end of the quickfix list,
" instead of replacing it. You could also put swap the order by using
" :Qfprepend
"
You can’t perform that action at this time.