Skip to content

Commit 8b5bc38

Browse files
author
amix
committed
Added two new plugins: vim-expand-region and vim-multiple-cursors.
They are both super useful. Read more on their GitHub pages for more info: https://github.com/terryma/vim-expand-region https://github.com/terryma/vim-multiple-cursors
1 parent c1bacbb commit 8b5bc38

19 files changed

Lines changed: 1743 additions & 1 deletion

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ I recommend reading the docs of these plugins to understand them better. Each of
7171
* [zencoding](https://github.com/mattn/zencoding-vim): Expanding abbreviation like zen-coding, very useful for editing XML, HTML.
7272
* [vim-indent-object](https://github.com/michaeljsmith/vim-indent-object): Defines a new text object representing lines of code at the same indent level. Useful for python/vim scripts
7373
* [taglist.vim](https://github.com/vim-scripts/taglist.vim): Source code browser (supports C/C++, java, perl, python, tcl, sql, php, etc)
74+
* [vim-multiple-cursors](https://github.com/terryma/vim-multiple-cursors): Sublime Text style multiple selections for Vim, CTRL+N is remapped to CTRL+A (due to YankRing)
75+
* [vim-expand-region](https://github.com/terryma/vim-expand-region): Allows you to visually select increasingly larger regions of text using the same key combination.
7476

7577

7678
## What color schemes are included?
@@ -134,6 +136,7 @@ Managing the [NERD Tree](https://github.com/scrooloose/nerdtree) plugin:
134136
map <leader>nf :NERDTreeFind<cr>
135137

136138
### Normal mode mappings
139+
137140
Fast saving of a buffer:
138141

139142
nmap <leader>w :w!<cr>
@@ -261,7 +264,7 @@ Bash like keys for the command line:
261264
cnoremap <C-P> <Up>
262265
cnoremap <C-N> <Down>
263266

264-
Write the file as sudo (only on Unix). [Vim tip](http://vim.wikia.com/wiki/Su-write):
267+
Write the file as sudo (only on Unix). Super useful when you open a file and you don't have permissions to save your changes. [Vim tip](http://vim.wikia.com/wiki/Su-write):
265268

266269
:W
267270

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright 2013 Terry Ma
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be included
12+
in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15+
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# vim-expand-region
2+
3+
## About
4+
[vim-expand-region] is a Vim plugin that allows you to visually select increasingly larger regions of text using the same key combination. It is similar to features from other editors:
5+
6+
- Emac's [expand region](https://github.com/magnars/expand-region.el)
7+
- IntelliJ's [syntax aware selection](http://www.jetbrains.com/idea/documentation/tips/#tips_code_editing)
8+
- Eclipse's [select enclosing element](http://stackoverflow.com/questions/4264047/intellij-ctrlw-equivalent-shortcut-in-eclipse)
9+
10+
<p align="center">
11+
<img src="https://raw.github.com/terryma/vim-expand-region/master/expand-region.gif" alt="vim-expand-region" />
12+
</p>
13+
14+
## Installation
15+
Install using [Pathogen], [Vundle], [Neobundle], or your favorite Vim package manager.
16+
17+
## Quick Start
18+
Press ```+``` to expand the visual selection and ```_``` to shrink it.
19+
20+
## Mapping
21+
Customize the key mapping if you don't like the default.
22+
23+
```
24+
map K <Plug>(expand_region_expand)
25+
map J <Plug>(expand_region_shrink)
26+
```
27+
28+
## Setting
29+
### Customize selected regions
30+
The plugin uses __your own__ text objects to determine the expansion. You can customize the text objects the plugin knows about with ```g:expand_region_text_objects```.
31+
32+
```vim
33+
" Default settings. (NOTE: Remove comments in dictionary before sourcing)
34+
let g:expand_region_text_objects = {
35+
\ 'iw' :0,
36+
\ 'iW' :0,
37+
\ 'i"' :0,
38+
\ 'i''' :0,
39+
\ 'i]' :1, " Support nesting of square brackets
40+
\ 'ib' :1, " Support nesting of parentheses
41+
\ 'iB' :1, " Support nesting of braces
42+
\ 'il' :0, " 'inside line'. Available through https://github.com/kana/vim-textobj-line
43+
\ 'ip' :0,
44+
\ 'ie' :0, " 'entire file'. Available through https://github.com/kana/vim-textobj-entire
45+
\ }
46+
```
47+
48+
You can extend the global default dictionary by calling ```expand_region#custom_text_objects```:
49+
50+
```vim
51+
" Extend the global default (NOTE: Remove comments in dictionary before sourcing)
52+
call expand_region#custom_text_objects({
53+
\ "\/\\n\\n\<CR>": 1, " Motions are supported as well. Here's a search motion that finds a blank line
54+
\ 'a]' :1, " Support nesting of 'around' brackets
55+
\ 'ab' :1, " Support nesting of 'around' parentheses
56+
\ 'aB' :1, " Support nesting of 'around' braces
57+
\ 'ii' :0, " 'inside indent'. Available through https://github.com/kana/vim-textobj-indent
58+
\ 'ai' :0, " 'around indent'. Available through https://github.com/kana/vim-textobj-indent
59+
\ })
60+
```
61+
62+
You can further customize the text objects dictionary on a per filetype basis by defining global variables like ```g:expand_region_text_objects_{ft}```.
63+
64+
```vim
65+
" Use the following setting for ruby. (NOTE: Remove comments in dictionary before sourcing)
66+
let g:expand_region_text_objects_ruby = {
67+
\ 'im' :0, " 'inner method'. Available through https://github.com/vim-ruby/vim-ruby
68+
\ 'am' :0, " 'around method'. Available through https://github.com/vim-ruby/vim-ruby
69+
\ }
70+
```
71+
72+
Note that this completely replaces the default dictionary. To extend the default on a per filetype basis, you can call ```expand_region#custom_text_objects``` by passing in the filetype in the first argument:
73+
74+
```vim
75+
" Use the global default + the following for ruby
76+
call expand_region#custom_text_objects('ruby', {
77+
\ 'im' :0,
78+
\ 'am' :0,
79+
\ })
80+
```
81+
82+
### Customize selection mode
83+
By default, after an expansion, the plugin leaves you in visual mode. If your ```selectmode```(h:selectmode)) contains ```cmd```, then the plugin will respect that setting and leave you in select mode. If you don't have ```selectmode``` set, but would like to default the expansion in select mode, you can use the global setting below:
84+
85+
```vim
86+
let g:expand_region_use_select_mode = 1
87+
```
88+
89+
[vim-expand-region]:http://github.com/terryma/vim-expand-region
90+
[Pathogen]:http://github.com/tpope/vim-pathogen
91+
[Vundle]:http://github.com/gmarik/vundle
92+
[Neobundle]:http://github.com/Shougo/neobundle.vim

0 commit comments

Comments
 (0)