From b125a96fb82c983bfd4ba3145c4e86a0eaecbac5 Mon Sep 17 00:00:00 2001 From: yan Date: Sat, 17 Dec 2011 13:27:01 -0800 Subject: [PATCH] Custom surround.vim ability to wrap #{ruby} variables using s# motion --- README.md | 54 +++++++++++++++++++---------- vim/plugin/settings/skwp-keymap.vim | 3 ++ vim/plugin/settings/surround.vim | 12 +++++++ 3 files changed, 51 insertions(+), 18 deletions(-) create mode 100644 vim/plugin/settings/surround.vim diff --git a/README.md b/README.md index f10e5f2..f7f1435 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,19 @@ -YADR: Yet Another Dotfile Repo -==== + _ _ _ + | | | | | | + | |___| |_____ __| | ____ + |_____ (____ |/ _ |/ ___) + _____| / ___ ( (_| | | + (_______\_____|\____|_| -**Pre-Alpha Preview Release - Please Report Bugs** + # Yet Another Dotfile Repo v0.7alpha + # Alpha Release Please Report Bugs -Warning: These dotfiles are opinionated! + git clone https://github.com/skwp/dotfiles ~/.dotfiles + ~/.dotfiles/bin/yadr/yadr init-plugins + + # Your dotfiles are safe! YADR will not + # overwrite anything. Please read on for + # install directions! This is a collection of best of breed tools from across the web, from scouring other people's dotfile repos, blogs, and projects. @@ -42,13 +52,10 @@ Before you start Installation --- -Coming Soon: gem-based installation - This project uses git submodules for its plugins, but this is handled for you by the **yadr** command. Please run: git clone https://github.com/skwp/dotfiles ~/.dotfiles - ~/.dotfiles/bin/yadr/yadr init-plugins NOTE: by default, YADR will not touch any of your files. You have to manually @@ -155,6 +162,12 @@ files contain key mappings as well (TODO: probably will move them out to skwp-ke * ,ru - Rails Unittest - synonym for :AV from rails.vim, opens up the corresponding test/spec to the file you're looking for, in a vertical split * \ss to run specs, \ll to run a given spec on a line - using my vim-ruby-conque plugin (https://github.com/skwp/vim-ruby-conque) + Surround.vim customizations + + * in plugin/settings/surround.vim (this folder contains all my customizations) + * the # key now surrounds with #{}, so - ysaw# surround around word #{foo} + * = surrounds with <%= erb tag %> and - for <% this %>, so yss= or yss- to wrap code + Search/Code Navigation * ,f - instantly Find definition of class (must have exuberant ctags installed) @@ -170,19 +183,26 @@ files contain key mappings as well (TODO: probably will move them out to skwp-ke * Cmd-k and Cmd-d to type underscores and dashes (use ), since they are so common in code but so far away from home row * ; instead of : - avoid Shift for common tasks, just hit semicolon to get to ex mode + * ,. to go to last edit location instead of '. because the apostrophe is hard on the pinky - Buffer/Window/Tab Manipulation + Tab Navigation - * ,m - NERDTree toggle - * Q - Quit a window, keep buffer alive (Ctrl-w,c) + * Cmd-H and Cmd-L - left an right on tabs + * Use Cmd-1..Cmd-0 to switch to a specific tab number (like iTerm) - and tabs have been set up to show numbers + + Window Navigation + + * H L I M - to move left, right, up, down between windows + * Q - Quit a window, keep buffer alive (Ctrl-w,c) * \Q - Quit window, kill buffer (:bw) + + **Splits*** + * vv - vertical split (Ctrl-w,v) * ss - horizontal split (Ctrl-w,s) - * H,L,I,M - to move left, right, up, down between windows - * Cmd-H and Cmd-L - left an right on tabs * ,, to zoom a window to max size and again to unzoom it (ZoomWin standard Ctrl-w,o) - * Use Cmd-1..Cmd-0 to switch to a specific tab number (like iTerm) - and tabs have been set up to show numbers * ,q to close the quickfix and ,oq to open the quickfix (great for lookin at Ack or GitGrep results) + * ,m - NERDTree toggle Utility @@ -238,6 +258,7 @@ Included vim plugins Utils + * yankring - effortless sanity for pasting. every time you yank something it goes into a buffer. after hitting p to paste, use ctrl-p or ctrl-n to cycle through the paste options. great for when you accidentally overwrite your yank with a delete * surround - super easy quote and tag manipulation - ysiw" - sourround inner word with quotes. ci"' - change inner double quotes to single quotes, etc * greplace - use :Gsearch to find across many files, replace inside the changes, then :Greplace to do a replace across all matches * ConqueTerm - embedded fully colorful shell inside your vim @@ -252,7 +273,7 @@ Included vim plugins General enhancements that don't add new commands - * IndexedSearch - when you do searches will show you "Match 2 of 4" in the status line, nothing new to learn + * IndexedSearch - when you do searches will show you "Match 2 of 4" in the status line * delimitMate - automatically closes quotes * syntastic - automatic syntax checking when you save the file * repeat - adds '.' (repeat command) support for complex commands like surround.vim. i.e. if you perform a surround and hit '.', it will Just Work (vim by default will only repeat the last piece of the complex command) @@ -270,7 +291,7 @@ YADR comes with a dead simple plugin manager that just uses git submodules, with You can update all the plugins easily: - yuv + yuv Delete a plugin (Coming Soon) @@ -345,12 +366,9 @@ Please explore these people's work. COMING SOON --- - * Full migration to tpope's pathogen format (~/.vim/bundle) for all plugins * Better isolation of customizations in smaller chunks, maybe as plugins * Automatic setup script to symlink all dotfiles, or just some selectively - - For more tips and tricks --- Follow my blog: http://yanpritzker.com diff --git a/vim/plugin/settings/skwp-keymap.vim b/vim/plugin/settings/skwp-keymap.vim index 129e2a0..84042b0 100644 --- a/vim/plugin/settings/skwp-keymap.vim +++ b/vim/plugin/settings/skwp-keymap.vim @@ -33,6 +33,9 @@ imap - " Don't have to use Shift to get into command mode, just hit semicolon nnoremap ; : +"Go to last edit location with ,. +nnoremap ,. '. + " ================== rails.vim " " Open corresponding unittest (or spec), alias for :AV in rails.vim diff --git a/vim/plugin/settings/surround.vim b/vim/plugin/settings/surround.vim new file mode 100644 index 0000000..1a0800b --- /dev/null +++ b/vim/plugin/settings/surround.vim @@ -0,0 +1,12 @@ +" via: http://whynotwiki.com/Vim +" Ruby +" Use v or # to get a variable interpolation (inside of a string)} +" ysiw# Wrap the token under the cursor in #{} +" v...s# Wrap the selection in #{} +let g:surround_113 = "#{\r}" " v +let g:surround_35 = "#{\r}" " # + +" Select text in an ERb file with visual mode and then press s- or s= +" Or yss- to do entire line. +let g:surround_45 = "<% \r %>" " - +let g:surround_61 = "<%= \r %>" " =