diff options
Diffstat (limited to 'plugin/AlignMapsPlugin.vim')
-rw-r--r-- | plugin/AlignMapsPlugin.vim | 253 |
1 files changed, 253 insertions, 0 deletions
diff --git a/plugin/AlignMapsPlugin.vim b/plugin/AlignMapsPlugin.vim new file mode 100644 index 0000000..7296f7f --- /dev/null +++ b/plugin/AlignMapsPlugin.vim | |||
@@ -0,0 +1,253 @@ | |||
1 | " AlignMapsPlugin: Alignment maps based upon <Align.vim> and <AlignMaps.vim> | ||
2 | " Maintainer: Dr. Charles E. Campbell. <NdrOchipS@PcampbellAfamily.Mbiz> | ||
3 | " Date: Jan 07, 2013 | ||
4 | " | ||
5 | " NOTE: the code herein needs vim 7.0 or later | ||
6 | " Copyright: Copyright (C) 1999-2012 Charles E. Campbell {{{1 | ||
7 | " Permission is hereby granted to use and distribute this code, | ||
8 | " with or without modifications, provided that this copyright | ||
9 | " notice is copied with it. Like anything else that's free, | ||
10 | " AlignMaps.vim is provided *as is* and comes with no warranty | ||
11 | " of any kind, either expressed or implied. By using this | ||
12 | " plugin, you agree that in no event will the copyright | ||
13 | " holder be liable for any damages resulting from the use | ||
14 | " of this software. | ||
15 | " Romans 1:20 For the invisible things of Him since the creation of the {{{1 | ||
16 | " world are clearly seen, being perceived through the things that are | ||
17 | " made, even His everlasting power and divinity; that they may be | ||
18 | " without excuse. | ||
19 | |||
20 | " --------------------------------------------------------------------- | ||
21 | " Usage: {{{1 | ||
22 | " Use 'a to mark beginning of to-be-aligned region, Alternative: use V | ||
23 | " move cursor to end of region, and execute map. (linewise visual mode) to | ||
24 | " The maps also set up marks 'y and 'z, and retain mark region, execute same | ||
25 | " 'a at the beginning of region. map. Uses 'a, 'y, and 'z. | ||
26 | " | ||
27 | " The start/end wrappers save and restore marks 'y and 'z. | ||
28 | " | ||
29 | " Although the comments indicate the maps use a leading backslash, | ||
30 | " actually they use <Leader> (:he mapleader), so the user can | ||
31 | " specify that the maps start how he or she prefers. | ||
32 | " | ||
33 | " Note: these maps all use <Align.vim>. | ||
34 | " | ||
35 | " Load Once: {{{1 | ||
36 | if &cp || exists("g:loaded_AlignMapsPlugin") | ||
37 | finish | ||
38 | endif | ||
39 | let s:keepcpo = &cpo | ||
40 | let g:loaded_AlignMapsPlugin = "v43" | ||
41 | set cpo&vim | ||
42 | |||
43 | " ===================================================================== | ||
44 | " Public Interface: {{{1 | ||
45 | com! AlignMapsClean :call AlignMaps#AlignMapsClean() | ||
46 | |||
47 | " ===================================================================== | ||
48 | " Maps: {{{1 | ||
49 | |||
50 | " --------------------------------------------------------------------- | ||
51 | " WS: wrapper start map (internal) {{{2 | ||
52 | " Produces a blank line above and below, marks with 'y and 'z | ||
53 | if !hasmapto('<Plug>WrapperStart') | ||
54 | map <unique> <SID>WS <Plug>AlignMapsWrapperStart | ||
55 | endif | ||
56 | nnoremap <silent> <script> <Plug>AlignMapsWrapperStart :set lz<CR>:call AlignMaps#WrapperStart(0)<CR> | ||
57 | vnoremap <silent> <script> <Plug>AlignMapsWrapperStart :<c-u>set lz<CR>:call AlignMaps#WrapperStart(1)<CR> | ||
58 | |||
59 | " --------------------------------------------------------------------- | ||
60 | " WE: wrapper end (internal) {{{2 | ||
61 | " Removes guard lines, restores marks y and z, and restores search pattern | ||
62 | if !hasmapto('<Plug>WrapperEnd') | ||
63 | nmap <unique> <SID>WE <Plug>AlignMapsWrapperEnd | ||
64 | endif | ||
65 | nnoremap <silent> <script> <Plug>AlignMapsWrapperEnd :call AlignMaps#WrapperEnd()<CR>:set nolz<CR> | ||
66 | |||
67 | " --------------------------------------------------------------------- | ||
68 | " Complex C-code alignment maps: {{{2 | ||
69 | if !hasmapto('<Plug>AM_a?') |call AlignMaps#MakeMap("a?")|endif | ||
70 | if !hasmapto('<Plug>AM_a,') |call AlignMaps#MakeMap("a,")|endif | ||
71 | if !hasmapto('<Plug>AM_a<') |call AlignMaps#MakeMap("a<")|endif | ||
72 | if !hasmapto('<Plug>AM_a=') |call AlignMaps#MakeMap("a=")|endif | ||
73 | if !hasmapto('<Plug>AM_a(') |call AlignMaps#MakeMap("a(")|endif | ||
74 | if !hasmapto('<Plug>AM_abox') |call AlignMaps#MakeMap("abox")|endif | ||
75 | if !hasmapto('<Plug>AM_acom') |call AlignMaps#MakeMap("acom")|endif | ||
76 | if !hasmapto('<Plug>AM_adcom')|call AlignMaps#MakeMap("adcom")|endif | ||
77 | if !hasmapto('<Plug>AM_aocom')|call AlignMaps#MakeMap("aocom")|endif | ||
78 | if !hasmapto('<Plug>AM_ascom')|call AlignMaps#MakeMap("ascom")|endif | ||
79 | if !hasmapto('<Plug>AM_adec') |call AlignMaps#MakeMap("adec")|endif | ||
80 | if !hasmapto('<Plug>AM_adef') |call AlignMaps#MakeMap("adef")|endif | ||
81 | if !hasmapto('<Plug>AM_afnc') |call AlignMaps#MakeMap("afnc")|endif | ||
82 | if !hasmapto('<Plug>AM_afnc') |call AlignMaps#MakeMap("afnc")|endif | ||
83 | |||
84 | " --------------------------------------------------------------------- | ||
85 | " Number alignment maps: {{{2 | ||
86 | if !hasmapto('<Plug>AM_aunum')|call AlignMaps#MakeMap("aunum")|endif | ||
87 | if !hasmapto('<Plug>AM_aenum')|call AlignMaps#MakeMap("aenum")|endif | ||
88 | if exists("g:alignmaps_euronumber") && !exists("g:alignmaps_usanumber") | ||
89 | if !hasmapto('<Plug>AM_anum')|call AlignMaps#MakeMap("anum")|endif | ||
90 | else | ||
91 | if !hasmapto('<Plug>AM_anum')|call AlignMaps#MakeMap("anum")|endif | ||
92 | endif | ||
93 | |||
94 | " --------------------------------------------------------------------- | ||
95 | " Plug maps: (the real thing) {{{2 | ||
96 | nnoremap <silent> <script> <Plug>AM_a? <SID>WS:AlignCtrl mIp1P1lC ? : : : : <CR>:'a,.Align<CR>:'a,'z-1s/\(\s\+\)? /?\1/e<CR><SID>WE | ||
97 | nnoremap <silent> <script> <Plug>AM_a, <SID>WS:'y,'zs/\(\S\)\s\+/\1 /ge<CR>'yjma'zk:call AlignMaps#CharJoiner(",")<cr>:silent 'y,'zg/,/call AlignMaps#FixMultiDec()<CR>'z:exe "norm \<Plug>AM_adec"<cr><SID>WE | ||
98 | nnoremap <silent> <script> <Plug>AM_a< <SID>WS:AlignCtrl mIp1P1=l << >><CR>:'a,.Align<CR><SID>WE | ||
99 | nnoremap <silent> <script> <Plug>AM_a( <SID>WS:AlignCtrl mIp0P1=l<CR>:'a,.Align [(,]<CR>:sil 'y+1,'z-1s/\(\s\+\),/,\1/ge<CR><SID>WE | ||
100 | nnoremap <silent> <script> <Plug>AM_a= <SID>WS:AlignCtrl mIp1P1=l<CR>:AlignCtrl g :=<CR>:'a,'zAlign :\==<CR><SID>WE | ||
101 | nnoremap <silent> <script> <Plug>AM_abox <SID>WS:let g:alignmaps_iws=substitute(getline("'a"),'^\(\s*\).*$','\1','e')<CR>:'a,'z-1s/^\s\+//e<CR>:'a,'z-1s/^.*$/@&@/<CR>:AlignCtrl m=p01P0w @<CR>:'a,.Align<CR>:'a,'z-1s/@/ * /<CR>:'a,'z-1s/@$/*/<CR>'aYP:s/./*/g<CR>0r/'zkYp:s/./*/g<CR>0r A/<Esc>:exe "'a-1,'z-1s/^/".g:alignmaps_iws."/e"<CR><SID>WE | ||
102 | nnoremap <silent> <script> <Plug>AM_acom <SID>WS:'a,.s/\/[*/]\/\=/@&@/e<CR>:'a,.s/\*\//@&/e<CR>:'y,'zs/^\( *\) @/\1@/e<CR>'zk:call AlignMaps#StdAlign(2)<CR>:'y,'zs/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE | ||
103 | nnoremap <silent> <script> <Plug>AM_adcom <SID>WS:'a,.v/^\s*\/[/*]/s/\/[*/]\*\=/@&@/e<CR>:'a,.v/^\s*\/[/*]/s/\*\//@&/e<CR>:'y,'zv/^\s*\/[/*]/s/^\( *\) @/\1@/e<CR>'zk:call AlignMaps#StdAlign(3)<cr>:'y,'zv/^\s*\/[/*]/s/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE | ||
104 | nnoremap <silent> <script> <Plug>AM_aocom <SID>WS:AlignPush<CR>:AlignCtrl g /[*/]<CR>:exe "norm \<Plug>AM_acom"<cr>:AlignPop<CR><SID>WE | ||
105 | nnoremap <silent> <script> <Plug>AM_ascom <SID>WS:'a,.s/\/[*/]/@&@/e<CR>:'a,.s/\*\//@&/e<CR>:silent! 'a,.g/^\s*@\/[*/]/s/@//ge<CR>:AlignCtrl v ^\s*\/[*/]<CR>:AlignCtrl g \/[*/]<CR>'zk:call AlignMaps#StdAlign(2)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'y,'zs/ @//eg<CR><SID>WE | ||
106 | nnoremap <silent> <script> <Plug>AM_adec <SID>WS:'a,'zs/\([^ \t/(]\)\([*&]\)/\1 \2/e<CR>:'y,'zv/^\//s/\([^ \t]\)\s\+/\1 /ge<CR>:'y,'zv/^\s*[*/]/s/\([^/][*&]\)\s\+/\1/ge<CR>:'y,'zv/^\s*[*/]/s/^\(\s*\%([a-zA-Z_][a-zA-Z_0-9<>:]*\s\+\%([a-zA-Z_*(&]\)\@=\)\+\)\([*(&]*\)\s*\([a-zA-Z0-9_()<>:]\+\)\s*\(\(\[.\{-}]\)*\)\s*\(=\)\=\s*\(.\{-}\)\=\s*;/\1@\2#@\3\4@\6@\7;@/e<CR>:'y,'zv/^\s*[*/]/s/\*\/\s*$/@*\//e<CR>:'y,'zv/^\s*[*/]/s/^\s\+\*/@@@@@* /e<CR>:'y,'zv/^\s*[*/]/s/^@@@@@\*\(.*[^*/]\)$/&@*/e<CR>'yjma'zk:AlignCtrl v ^\s*[*/#]<CR>:call AlignMaps#StdAlign(1)<cr>:'y,'zv/^\s*[*/]/s/@ //ge<CR>:'y,'zv/^\s*[*/]/s/\(\s*\);/;\1/e<CR>:'y,'zv/^#/s/# //e<CR>:'y,'zv/^\s\+[*/#]/s/\([^/*]\)\(\*\+\)\( \+\)/\1\3\2/e<CR>:'y,'zv/^\s\+[*/#]/s/\((\+\)\( \+\)\*/\2\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/^\(\s\+\) \*/\1*/e<CR>:'y,'zv/^\s\+[*/#]/s/[ \t@]*$//e<CR>:'y,'zs/^[*]/ */e<CR><SID>WE | ||
107 | nnoremap <silent> <script> <Plug>AM_adef <SID>WS:AlignPush<CR>:AlignCtrl v ^\s*\(\/\*\<bar>\/\/\)<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/^\(\s*\)#\(\s\)*define\s*\(\I[a-zA-Z_0-9(),]*\)\s*\(.\{-}\)\($\<Bar>\/\*\)/#\1\2define @\3@\4@\5/e<CR>:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/\($\<Bar>\*\/\)/@&/e<CR>'zk:call AlignMaps#StdAlign(1)<cr>'yjma'zk:'a,.v/^\s*\(\/\*\<bar>\/\/\)/s/ @//g<CR><SID>WE | ||
108 | nnoremap <silent> <script> <Plug>AM_afnc :<c-u>set lz<CR>:silent call AlignMaps#Afnc()<CR>:set nolz<CR> | ||
109 | nnoremap <silent> <script> <Plug>AM_aunum <SID>WS:'a,'zs/\([-+]\=\d\+\)\([eE][-+]\d\+\)\=/\1#\2/ge<CR>:'a,'zs/\([.eE][-+]\=\d\+\)#/\1/ge<CR>:'a,'zs/#\././ge<CR>:'a,'zs/[-+]\=\%(\d\+\%([.#]\d*\)\=\<bar>[.#]\d\+\)\%([eE][-+]\=\d\+\)\=/@&@/ge<CR>:AlignCtrl Imp0P0r<CR>:'a,'zAlign [@#.]<CR>:'a,'zs/\([.#]\)\(\s\+\)\(\d*\%([eE][-+]\=\d\+\)\=\)@/\1\3\2@/ge<CR>:'a,'zs/@//<CR>:'a,'zs/[#@]/ /ge<CR><SID>WE | ||
110 | nnoremap <silent> <script> <Plug>AM_aenum <SID>WS:'a,'zs/\([-+]\=\d\+\)\([eE][-+]\d\+\)\=/\1#\2/ge<CR>:'a,'zs/\([,eE][-+]\=\d\+\)#/\1/ge<CR>:'a,'zs/#,/,/ge<CR>:'a,'zs/[-+]\=\%(\d\+\%([,#]\d*\)\=\<bar>[,#]\d\+\)\%([eE][-+]\=\d\+\)\=/@&@/ge<CR>:AlignCtrl Imp0P0r<CR>:'a,'zAlign [@#,]<CR>:'a,'zs/\([,#]\)\(\s\+\)\(\d*\%([eE][-+]\=\d\+\)\=\)@/\1\3\2@/ge<CR>:'a,'zs/@//<CR>:'a,'zs/[#@]/ /ge<CR><SID>WE | ||
111 | " --------------------------------------------------------------------- | ||
112 | " html table alignment {{{2 | ||
113 | if !hasmapto('<Plug>AM_Htd')|map <unique> <Leader>Htd <Plug>AM_Htd|endif | ||
114 | map <silent> <script> <Plug>AM_Htd <SID>WS:'y,'zs%<[tT][rR]><[tT][dD][^>]\{-}>\<Bar></[tT][dD]><[tT][dD][^>]\{-}>\<Bar></[tT][dD]></[tT][rR]>%@&@%g<CR>'yjma'zk:AlignCtrl m=Ilp1P0 @<CR>:'a,.Align<CR>:'y,'zs/ @/@/<CR>:'y,'zs/@ <[tT][rR]>/<[tT][rR]>/ge<CR>:'y,'zs/@//ge<CR><SID>WE | ||
115 | |||
116 | " --------------------------------------------------------------------- | ||
117 | " character-based right-justified alignment maps {{{2 | ||
118 | if !hasmapto('<Plug>AM_T|')|call AlignMaps#MakeMap("T|")|endif | ||
119 | if !hasmapto('<Plug>AM_T#') |call AlignMaps#MakeMap("T#")|endif | ||
120 | if !hasmapto('<Plug>AM_T,') |call AlignMaps#MakeMap("T,")|endif | ||
121 | if !hasmapto('<Plug>AM_Ts,') |call AlignMaps#MakeMap("Ts,")|endif | ||
122 | if !hasmapto('<Plug>AM_T:') |call AlignMaps#MakeMap("T:")|endif | ||
123 | if !hasmapto('<Plug>AM_T;') |call AlignMaps#MakeMap("T;")|endif | ||
124 | if !hasmapto('<Plug>AM_T<') |call AlignMaps#MakeMap("T<")|endif | ||
125 | if !hasmapto('<Plug>AM_T=') |call AlignMaps#MakeMap("T=")|endif | ||
126 | if !hasmapto('<Plug>AM_T?') |call AlignMaps#MakeMap("T?")|endif | ||
127 | if !hasmapto('<Plug>AM_T@') |call AlignMaps#MakeMap("T@")|endif | ||
128 | if !hasmapto('<Plug>AM_TW@') |call AlignMaps#MakeMap("TW@")|endif | ||
129 | if !hasmapto('<Plug>AM_Tab') |call AlignMaps#MakeMap("Tab")|endif | ||
130 | if !hasmapto('<Plug>AM_Tsp') |call AlignMaps#MakeMap("Tsp")|endif | ||
131 | if !hasmapto('<Plug>AM_T~') |call AlignMaps#MakeMap("T~")|endif | ||
132 | |||
133 | nnoremap <silent> <script> <Plug>AM_T| <SID>WS:AlignCtrl mIp0P0=r <Bar><CR>:'a,.Align<CR><SID>WE | ||
134 | nnoremap <silent> <script> <Plug>AM_T# <SID>WS:AlignCtrl mIp0P0=r #<CR>:'a,.Align<CR><SID>WE | ||
135 | nnoremap <silent> <script> <Plug>AM_T, <SID>WS:AlignCtrl mIp0P1=r ,<CR>:'a,.Align<CR><SID>WE | ||
136 | nnoremap <silent> <script> <Plug>AM_Ts, <SID>WS:AlignCtrl mIp0P1=r ,<CR>:'a,.Align<CR>:'a,.s/\(\s*\),/,\1/ge<CR><SID>WE | ||
137 | nnoremap <silent> <script> <Plug>AM_T: <SID>WS:AlignCtrl mIp1P1=r :<CR>:'a,.Align<CR><SID>WE | ||
138 | nnoremap <silent> <script> <Plug>AM_T; <SID>WS:AlignCtrl mIp0P0=r ;<CR>:'a,.Align<CR><SID>WE | ||
139 | nnoremap <silent> <script> <Plug>AM_T< <SID>WS:AlignCtrl mIp0P0=r <<CR>:'a,.Align<CR><SID>WE | ||
140 | nnoremap <silent> <script> <Plug>AM_T= <SID>WS:'a,'z-1s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'z-1s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'z-1s/; */;@/e<CR>:'a,'z-1s/==/\="\<Char-0x0f>\<Char-0x0f>"/ge<CR>:'a,'z-1s/!=/\x="!\<Char-0x0f>"/ge<CR>:AlignCtrl mIp1P1=r = @<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s/; *@/;/e<CR>:'a,'z-1s/; *$/;/e<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-1s/\xff/=/ge<CR><SID>WE:exe "norm <Plug>acom" | ||
141 | nnoremap <silent> <script> <Plug>AM_T? <SID>WS:AlignCtrl mIp0P0=r ?<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE | ||
142 | nnoremap <silent> <script> <Plug>AM_T@ <SID>WS:AlignCtrl mIp0P0=r @<CR>:'a,.Align<CR><SID>WE | ||
143 | nnoremap <silent> <script> <Plug>AM_TW@ <SID>WS:AlignCtrl mWp0P0=r @<CR>:'a,.Align<CR><SID>WE | ||
144 | nnoremap <silent> <script> <Plug>AM_Tab <SID>WS:'a,.s/^\(\t*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\t','@','g'),'\')/<CR>:AlignCtrl mI=r @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE | ||
145 | nnoremap <silent> <script> <Plug>AM_Tsp <SID>WS:'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=r @<CR>:'a,.Align<CR>:'y+1,'z-1s/@/ /g<CR><SID>WE | ||
146 | nnoremap <silent> <script> <Plug>AM_T~ <SID>WS:AlignCtrl mIp0P0=r ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE | ||
147 | |||
148 | " --------------------------------------------------------------------- | ||
149 | " character-based left-justified alignment maps {{{2 | ||
150 | if !hasmapto('<Plug>AM_t|','n') |call AlignMaps#MakeMap("t|")|endif | ||
151 | if !hasmapto('<Plug>AM_t#','n') |call AlignMaps#MakeMap("t#")|endif | ||
152 | if !hasmapto('<Plug>AM_t,','n') |call AlignMaps#MakeMap("t,")|endif | ||
153 | if !hasmapto('<Plug>AM_t:','n') |call AlignMaps#MakeMap("t:")|endif | ||
154 | if !hasmapto('<Plug>AM_t;','n') |call AlignMaps#MakeMap("t;")|endif | ||
155 | if !hasmapto('<Plug>AM_t<','n') |call AlignMaps#MakeMap("t<")|endif | ||
156 | if !hasmapto('<Plug>AM_t=','n') |call AlignMaps#MakeMap("t=")|endif | ||
157 | if !hasmapto('<Plug>AM_ts,','n') |call AlignMaps#MakeMap("ts,")|endif | ||
158 | if !hasmapto('<Plug>AM_ts:','n') |call AlignMaps#MakeMap("ts:")|endif | ||
159 | if !hasmapto('<Plug>AM_ts;','n') |call AlignMaps#MakeMap("ts;")|endif | ||
160 | if !hasmapto('<Plug>AM_ts<','n') |call AlignMaps#MakeMap("ts<")|endif | ||
161 | if !hasmapto('<Plug>AM_ts=','n') |call AlignMaps#MakeMap("ts=")|endif | ||
162 | if !hasmapto('<Plug>AM_w=','n') |call AlignMaps#MakeMap("w=")|endif | ||
163 | if !hasmapto('<Plug>AM_t?','n') |call AlignMaps#MakeMap("t?")|endif | ||
164 | if !hasmapto('<Plug>AM_t~','n') |call AlignMaps#MakeMap("t~")|endif | ||
165 | if !hasmapto('<Plug>AM_t@','n') |call AlignMaps#MakeMap("t@")|endif | ||
166 | if !hasmapto('<Plug>AM_tW@','n') |call AlignMaps#MakeMap("tW@")|endif | ||
167 | if !hasmapto('<Plug>AM_m=','n') |call AlignMaps#MakeMap("m=")|endif | ||
168 | if !hasmapto('<Plug>AM_tab','n') |call AlignMaps#MakeMap("tab")|endif | ||
169 | if !hasmapto('<Plug>AM_tml','n') |call AlignMaps#MakeMap("tml")|endif | ||
170 | if !hasmapto('<Plug>AM_tsp','n') |call AlignMaps#MakeMap("tsp")|endif | ||
171 | if !hasmapto('<Plug>AM_tsq','n') |call AlignMaps#MakeMap("tsq")|endif | ||
172 | if !hasmapto('<Plug>AM_tt','n') |call AlignMaps#MakeMap("tt")|endif | ||
173 | if !hasmapto('<Plug>AM_tab','n') |call AlignMaps#MakeMap("tab")|endif | ||
174 | |||
175 | " <Plug> normal mode mappings | ||
176 | nnoremap <silent> <script> <Plug>AM_t| <SID>WS:AlignCtrl mIp0P0=l <Bar><CR>:'a,.Align<CR><SID>WE | ||
177 | nnoremap <silent> <script> <Plug>AM_t# <SID>WS:AlignCtrl mIp0P0=l #<CR>:'a,.Align<CR><SID>WE | ||
178 | nnoremap <silent> <script> <Plug>AM_t, <SID>WS:AlignCtrl mIp0P1=l ,<CR>:'a,.Align<CR><SID>WE | ||
179 | nnoremap <silent> <script> <Plug>AM_t: <SID>WS:AlignCtrl mIp1P1=l :<CR>:'a,.Align<CR><SID>WE | ||
180 | nnoremap <silent> <script> <Plug>AM_t; <SID>WS:AlignCtrl mIp0P1=l ;<CR>:'a,.Align<CR>:sil 'y,'zs/\( *\);/;\1/ge<CR><SID>WE | ||
181 | nnoremap <silent> <script> <Plug>AM_t< <SID>WS:AlignCtrl mIp0P0=l <<CR>:'a,.Align<CR><SID>WE | ||
182 | nnoremap <silent> <script> <Plug>AM_t= <SID>WS:call AlignMaps#Equals()<CR><SID>WE | ||
183 | nnoremap <silent> <script> <Plug>AM_ts, <SID>WS:AlignCtrl mIp0P1=l #\zs<CR>:'a,.Align<CR><SID>WE | ||
184 | nnoremap <silent> <script> <Plug>AM_ts, <SID>WS:AlignCtrl mIp0P1=l ,\zs<CR>:'a,.Align<CR><SID>WE | ||
185 | nnoremap <silent> <script> <Plug>AM_ts: <SID>WS:AlignCtrl mIp1P1=l :\zs<CR>:'a,.Align<CR><SID>WE | ||
186 | nnoremap <silent> <script> <Plug>AM_ts; <SID>WS:AlignCtrl mIp1P1=l ;\zs<CR>:'a,.Align<CR><SID>WE | ||
187 | nnoremap <silent> <script> <Plug>AM_ts< <SID>WS:AlignCtrl mIp1P1=l <\zs<CR>:'a,.Align<CR><SID>WE | ||
188 | nnoremap <silent> <script> <Plug>AM_ts= <SID>WS:AlignCtrl mIp1P1=l =\zs<CR>:'a,.Align<CR><SID>WE | ||
189 | nnoremap <silent> <script> <Plug>AM_w= <SID>WS:'a,'zg/=/s/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zg/=/s@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zg/=/s/==/\="\<Char-0x0f>\<Char-0x0f>"/ge<CR>:'a,'zg/=/s/!=/\="!\<Char-0x0f>"/ge<CR>'zk:AlignCtrl mWp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1g/=/Align<CR>:'a,'z-1g/=/s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1g/=/s/\( \+\);/;\1/ge<CR>:'a,'z-1v/^\s*\/[*/]/s/\/[*/]/@&@/e<CR>:'a,'z-1v/^\s*\/[*/]/s/\*\//@&/e<CR>'zk:call AlignMaps#StdAlign(1)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1g/=/s/\xff/=/ge<CR>:'y,'zg/=/s/ @//eg<CR><SID>WE | ||
190 | nnoremap <silent> <script> <Plug>AM_t? <SID>WS:AlignCtrl mIp0P0=l ?<CR>:'a,.Align<CR>:.,'zs/ \( *\);/;\1/ge<CR><SID>WE | ||
191 | nnoremap <silent> <script> <Plug>AM_t~ <SID>WS:AlignCtrl mIp0P0=l ~<CR>:'a,.Align<CR>:'y,'zs/ \( *\);/;\1/ge<CR><SID>WE | ||
192 | nnoremap <silent> <script> <Plug>AM_t@ <SID>WS:call AlignMaps#StdAlign(1)<cr><SID>WE | ||
193 | nnoremap <silent> <script> <Plug>AM_tW@ <SID>WS:call AlignMaps#StdAlign(2)<cr><SID>WE | ||
194 | nnoremap <silent> <script> <Plug>AM_m= <SID>WS:'a,'zs/\s\+\([*/+\-%<Bar>&\~^]\==\)/ \1/e<CR>:'a,'zs@ \+\([*/+\-%<Bar>&\~^]\)=@\1=@ge<CR>:'a,'zs/==/\="\<Char-0x0f>\<Char-0x0f>"/ge<CR>:'a,'zs/!=/\="!\<Char-0x0f>"/ge<CR>'zk:AlignCtrl mIp1P1=l =<CR>:AlignCtrl g =<CR>:'a,'z-1Align<CR>:'a,'z-1s@\([*/+\-%<Bar>&\~^!=]\)\( \+\)=@\2\1=@ge<CR>:'a,'z-1s/\( \+\);/;\1/ge<CR>:'a,'z-s/%\ze[^=]/ @%@ /e<CR>'zk:call AlignMaps#StdAlign(1)<cr>:'y,'zs/^\(\s*\) @/\1/e<CR>:'a,'z-1s/\xff/=/ge<CR>:'y,'zs/ @//eg<CR><SID>WE | ||
195 | nnoremap <silent> <script> <Plug>AM_tab <SID>WS:'a,.s/^\(\t*\)\(.*\)$/\=submatch(1).escape(substitute(submatch(2),'\t',"\<Char-0x0f>",'g'),'\')/<CR>:if &ts == 1<bar>exe "AlignCtrl mI=lp0P0 \<Char-0x0f>"<bar>else<bar>exe "AlignCtrl mI=l"<bar>endif<CR>:'a,.Align <Char-0x0f><CR>:exe "'y+1,'z-1s/\<Char-0x0f>/".((&ts == 1)? '\t' : ' ')."/g"<CR><SID>WE | ||
196 | nnoremap <silent> <script> <Plug>AM_tml <SID>WS:AlignCtrl mWp1P0=l \\\@<!\\\s*$<CR>:'a,.Align<CR><SID>WE | ||
197 | nnoremap <silent> <script> <Plug>AM_tsp <SID>WS:keepj 'a,.s/^\(\s*\)\(.*\)/\=submatch(1).escape(substitute(submatch(2),'\s\+','@','g'),'\')/<CR>:AlignCtrl mI=lp0P0 @<CR>:'a,.Align<CR>:keepj 'y+1,'z-1s/@/ /g<CR><SID>WE | ||
198 | nnoremap <silent> <script> <Plug>AM_tsq <SID>WS:'a,.AlignReplaceQuotedSpaces<CR>:keepj 'a,.s/^\(\s*\)\(.*\)/\=submatch(1).substitute(submatch(2),'\s\+','@','g')/<CR>:AlignCtrl mIp0P0=l @<CR>:'a,.Align<CR>:keepj 'y+1,'z-1s/[%@]/ /g<CR><SID>WE | ||
199 | nnoremap <silent> <script> <Plug>AM_tt <SID>WS:AlignCtrl mIp1P1=l \\\@<!& \\\\<CR>:'a,.Align<CR><SID>WE | ||
200 | |||
201 | " ===================================================================== | ||
202 | " Menu Support: {{{1 | ||
203 | " ma ..move.. use menu | ||
204 | " v V or ctrl-v ..move.. use menu | ||
205 | if has("menu") && has("gui_running") && &go =~# 'm' && !exists("s:firstmenu") | ||
206 | let s:firstmenu= 1 | ||
207 | if !exists("g:DrChipTopLvlMenu") | ||
208 | let g:DrChipTopLvlMenu= "DrChip." | ||
209 | endif | ||
210 | if g:DrChipTopLvlMenu != "" | ||
211 | let s:mapleader = exists("g:mapleader")? g:mapleader : '\' | ||
212 | let s:emapleader= escape(s:mapleader,'\ ') | ||
213 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.<<\ and\ >><tab>'.s:emapleader.'a< '.s:mapleader.'a<' | ||
214 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Assignment\ =<tab>'.s:emapleader.'t= '.s:mapleader.'t=' | ||
215 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Assignment\ :=<tab>'.s:emapleader.'a= '.s:mapleader.'a=' | ||
216 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Backslashes<tab>'.s:emapleader.'tml '.s:mapleader.'tml' | ||
217 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Breakup\ Comma\ Declarations<tab>'.s:emapleader.'a, '.s:mapleader.'a,' | ||
218 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.C\ Comment\ Box<tab>'.s:emapleader.'abox '.s:mapleader.'abox' | ||
219 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas<tab>'.s:emapleader.'t, '.s:mapleader.'t,' | ||
220 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas<tab>'.s:emapleader.'ts, '.s:mapleader.'ts,' | ||
221 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Commas\ With\ Strings<tab>'.s:emapleader.'tsq '.s:mapleader.'tsq' | ||
222 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Comments<tab>'.s:emapleader.'acom '.s:mapleader.'acom' | ||
223 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Comments\ Only<tab>'.s:emapleader.'aocom '.s:mapleader.'aocom' | ||
224 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Declaration\ Comments<tab>'.s:emapleader.'adcom '.s:mapleader.'adcom' | ||
225 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Declarations<tab>'.s:emapleader.'adec '.s:mapleader.'adec' | ||
226 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Definitions<tab>'.s:emapleader.'adef '.s:mapleader.'adef' | ||
227 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Function\ Header<tab>'.s:emapleader.'afnc '.s:mapleader.'afnc' | ||
228 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Html\ Tables<tab>'.s:emapleader.'Htd '.s:mapleader.'Htd' | ||
229 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.(\.\.\.)?\.\.\.\ :\ \.\.\.<tab>'.s:emapleader.'a? '.s:mapleader.'a?' | ||
230 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers<tab>'.s:emapleader.'anum '.s:mapleader.'anum' | ||
231 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers\ (American-Style)<tab>'.s:emapleader.'aunum <Leader>aunum '.s:mapleader.'aunum <Leader>aunum' | ||
232 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Numbers\ (Euro-Style)<tab>'.s:emapleader.'aenum '.s:mapleader.'aenum' | ||
233 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Spaces\ (Left\ Justified)<tab>'.s:emapleader.'tsp '.s:mapleader.'tsp' | ||
234 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Spaces\ (Right\ Justified)<tab>'.s:emapleader.'Tsp '.s:mapleader.'Tsp' | ||
235 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Statements\ With\ Percent\ Style\ Comments<tab>'.s:emapleader.'m= '.s:mapleader.'m=' | ||
236 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ <<tab>'.s:emapleader.'t< '.s:mapleader.'t<' | ||
237 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ \|<tab>'.s:emapleader.'t\| '.s:mapleader.'t|' | ||
238 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ @<tab>'.s:emapleader.'t@ '.s:mapleader.'t@' | ||
239 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Symbol\ #<tab>'.s:emapleader.'t# '.s:mapleader.'t#' | ||
240 | exe 'menu '.g:DrChipTopLvlMenu.'AlignMaps.Tabs<tab>'.s:emapleader.'tab '.s:mapleader.'tab' | ||
241 | unlet s:mapleader | ||
242 | unlet s:emapleader | ||
243 | endif | ||
244 | endif | ||
245 | |||
246 | " ===================================================================== | ||
247 | " Restore: {{{1 | ||
248 | let &cpo= s:keepcpo | ||
249 | unlet s:keepcpo | ||
250 | |||
251 | " ============================================================================== | ||
252 | " Modelines: {{{1 | ||
253 | " vim: ts=4 nowrap fdm=marker | ||