@@ -131,6 +131,7 @@ func! AlternateFile(splitWindow, ...)
131131endfunc
132132comm! -nargs =? A call AlternateFile (0 , <f-args> )
133133comm! -nargs =? AS call AlternateFile (1 , <f-args> )
134+ comm! -nargs =? AV call AlternateFile (2 , <f-args> )
134135
135136
136137" Function : BufferOrFileExists (PRIVATE)
@@ -154,43 +155,49 @@ endfunction
154155" Returns : nothing
155156" Author : Michael Sharpe <feline@irendi.com>
156157function ! <SID> FindOrCreateBuffer (filename, doSplit)
157- " Check to see if the buffer is already open before re-opening it.
158- let bufName = bufname (a: filename )
159- if (bufName == " " )
160- " Buffer did not exist....create it
161- if (a: doSplit != 0 )
162- execute " :split " . a: filename
163- else
164- execute " :e " . a: filename
165- endif
166- else
167- " Buffer was already open......check to see if it is in a window
168- let bufWindow = bufwinnr (a: filename )
169- if (bufWindow == -1 )
170- if (a: doSplit != 0 )
171- execute " :sbuffer " . a: filename
172- else
173- execute " :buffer " . a: filename
174- endif
175- else
176- " search the windows for the target window
177- if bufWindow != winnr ()
178- " only search if the current window does not contain the buffer
179- execute " normal \<C-W> b"
180- let winNum = winnr ()
181- while (winNum != bufWindow && winNum > 0 )
182- execute " normal \<C-W> k"
183- let winNum = winNum - 1
184- endwhile
185- if (0 == winNum)
186- " something wierd happened...open the buffer
187- if (a: doSplit != 0 )
188- execute " :split " . a: filename
189- else
190- execute " :e " . a: filename
191- endif
192- endif
193- endif
194- endif
195- endif
158+ " Check to see if the buffer is already open before re-opening it.
159+ let bufName = bufname (a: filename )
160+ if (bufName == " " )
161+ " Buffer did not exist....create it
162+ if (a: doSplit == 2 )
163+ execute " :vert split " . a: filename
164+ elseif (a: doSplit == 1 )
165+ execute " :split " . a: filename
166+ else
167+ execute " :e " . a: filename
168+ endif
169+ else
170+ " Buffer was already open......check to see if it is in a window
171+ let bufWindow = bufwinnr (a: filename )
172+ if (bufWindow == -1 )
173+ if (a: doSplit == 2 )
174+ execute " :vert sbuffer " . a: filename
175+ elseif (a: doSplit == 1 )
176+ execute " :sbuffer " . a: filename
177+ else
178+ execute " :buffer " . a: filename
179+ endif
180+ else
181+ " search the windows for the target window
182+ if bufWindow != winnr ()
183+ " only search if the current window does not contain the buffer
184+ execute " normal \<C-W> b"
185+ let winNum = winnr ()
186+ while (winNum != bufWindow && winNum > 0 )
187+ execute " normal \<C-W> k"
188+ let winNum = winNum - 1
189+ endwhile
190+ if (0 == winNum)
191+ " something wierd happened...open the buffer
192+ if (a: doSplit == 2 )
193+ execute " :vert split " . a: filename
194+ elseif (a: doSplit == 1 )
195+ execute " :split " . a: filename
196+ else
197+ execute " :e " . a: filename
198+ endif
199+ endif
200+ endif
201+ endif
202+ endif
196203endfunction
0 commit comments