Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 1b577bc
Showing
3 changed files
with
119 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
See the [contribution guidelines for pathogen.vim](https://github.com/tpope/vim-pathogen/blob/master/CONTRIBUTING.markdown). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
# vim-sexp mappings for regular people | ||
|
||
I'm really liking my first impressions of [vim-sexp][]. It's like paredit | ||
minus a couple of parts of paredit that are impossibly tricky to implement in | ||
Vim. I'm not too keen on some of the default mappings, though, and in | ||
particular the mappings using the meta key are just an absolute deal breaker | ||
for me and everyone else that uses Vim in a terminal. So I made and published | ||
my own, in an attempt to define a more accessible standard. | ||
|
||
[vim-sexp]: https://github.com/guns/vim-sexp | ||
|
||
## Installation | ||
|
||
You know the drill. Here's a copy and paste to install the works with | ||
[pathogen.vim](https://github.com/tpope/vim-pathogen). | ||
|
||
cd ~/.vim/bundle | ||
git clone git://github.com/tpope/vim-sexp-mappings-for-regular-people.git | ||
git clone git://github.com/guns/vim-sexp.git | ||
git clone git://github.com/tpope/vim-repeat.git | ||
git clone git://github.com/tpope/vim-surround.git | ||
|
||
## Provided mappings | ||
|
||
These mappings supplement rather than replace the existing mappings (despite | ||
vim-sexp's best efforts to thwart this), so if you have muscle memory, fear | ||
not. | ||
|
||
### Motion mappings | ||
|
||
Vim-sexp uses meta mappings to move element-wise. I've taken over the WORD | ||
motions--`W`, `B`, `E`, `gE`--instead, operating under the theory that those | ||
aren't nearly as useful in a language where so many punctuation marks are | ||
identifier characters. This might be a terrible idea. | ||
|
||
### List manipulation mappings | ||
|
||
More meta madness in the defaults here. I've taken `>f` and `<f` to move a | ||
form and `>e` and `<e` to move an element. | ||
|
||
Slurpage and barfage are handled by `>)`, `<)`, `<(`, and `<)`, where the | ||
angle bracket indicates the direction, and the parenthesis indicates which end | ||
to operate on. | ||
|
||
### Insertion mappings | ||
|
||
Use `<I` and `>I` to insert at the beginning and ending of a form. | ||
|
||
### Mappings inspired by surround.vim | ||
|
||
Note that surround.vim out of the box works great with the sexp.vim motions | ||
and text objects. Use `ysaf)`, for example, to surround the current form with | ||
parentheses. To this, we add a few more mappings: | ||
|
||
* `dsf`: splice (delete surroundings of form) | ||
* `cse(`/`cse)`/`cseb`: surround element in parentheses | ||
* `cse[`/`cse]`: surround element in brackets | ||
* `cse{`/`cse}`: surround element in braces | ||
|
||
## License | ||
|
||
Copyright © Tim Pope. Distributed under the same terms as Vim itself. | ||
See `:help license`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
" after/plugin/sexp.vim - Sexp mappings for regular people | ||
" Maintainer: Tim Pope <code@tpope.net> | ||
|
||
if !exists('g:sexp_loaded') || exists("g:after_loaded_sexp") | ||
finish | ||
endif | ||
let g:after_sexp_loaded = 1 | ||
|
||
augroup sexp | ||
autocmd! | ||
execute 'autocmd FileType' get(g:, 'sexp_filetypes', 'lisp,scheme,clojure') 'call s:sexp_mappings()' | ||
augroup END | ||
|
||
function! s:map_sexp_wrap(type, target, left, right, pos) | ||
execute (a:type ==# 'v' ? 'x' : 'n').'noremap' | ||
\ '<buffer><silent>' a:target ':<C-U>let b:sexp_count = v:count<Bar>exe "normal! m`"<Bar>' | ||
\ . 'call sexp#wrap("'.a:type.'", "'.a:left.'", "'.a:right.'", '.a:pos.', 0)' | ||
\ . '<Bar>silent! call repeat#set("'.a:target.'", v:count)<CR>' | ||
endfunction | ||
|
||
function! s:sexp_mappings() abort | ||
call s:map_sexp_wrap('e', 'cseb', '(', ')', 0) | ||
call s:map_sexp_wrap('e', 'cse(', '(', ')', 0) | ||
call s:map_sexp_wrap('e', 'cse)', '(', ')', 1) | ||
call s:map_sexp_wrap('e', 'cse[', '[', ']', 0) | ||
call s:map_sexp_wrap('e', 'cse]', '[', ']', 1) | ||
call s:map_sexp_wrap('e', 'cse{', '{', '}', 0) | ||
call s:map_sexp_wrap('e', 'cse}', '{', '}', 1) | ||
|
||
nmap <buffer> dsf <Plug>(sexp_splice_list) | ||
nmap <buffer> B <Plug>(sexp_move_to_prev_element_head) | ||
nmap <buffer> W <Plug>(sexp_move_to_next_element_head) | ||
nmap <buffer> gE <Plug>(sexp_move_to_prev_element_tail) | ||
nmap <buffer> E <Plug>(sexp_move_to_next_element_tail) | ||
xmap <buffer> B <Plug>(sexp_move_to_prev_element_head) | ||
xmap <buffer> W <Plug>(sexp_move_to_next_element_head) | ||
xmap <buffer> gE <Plug>(sexp_move_to_prev_element_tail) | ||
xmap <buffer> E <Plug>(sexp_move_to_next_element_tail) | ||
omap <buffer> B <Plug>(sexp_move_to_prev_element_head) | ||
omap <buffer> W <Plug>(sexp_move_to_next_element_head) | ||
omap <buffer> gE <Plug>(sexp_move_to_prev_element_tail) | ||
omap <buffer> E <Plug>(sexp_move_to_next_element_tail) | ||
nmap <buffer> <I <Plug>(sexp_insert_at_list_head) | ||
nmap <buffer> >I <Plug>(sexp_insert_at_list_tail) | ||
nmap <buffer> <f <Plug>(sexp_swap_list_backward) | ||
nmap <buffer> >f <Plug>(sexp_swap_list_forward) | ||
nmap <buffer> <e <Plug>(sexp_swap_element_backward) | ||
nmap <buffer> >e <Plug>(sexp_swap_element_forward) | ||
nmap <buffer> >( <Plug>(sexp_emit_head_element) | ||
nmap <buffer> <) <Plug>(sexp_emit_tail_element) | ||
nmap <buffer> <( <Plug>(sexp_capture_prev_element) | ||
nmap <buffer> >) <Plug>(sexp_capture_next_element) | ||
endfunction |