annotate runtime/pack/dist/opt/editexisting/plugin/editexisting.vim @ 8771:57cafbda13ad v7.4.1674

commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359 Author: Bram Moolenaar <Bram@vim.org> Date: Mon Mar 28 21:04:37 2016 +0200 patch 7.4.1674 Problem: The editexisting plugin has to be copied or sourced to be used. Solution: Turn it into a package.
author Christian Brabandt <cb@256bit.org>
date Mon, 28 Mar 2016 21:15:06 +0200
parents
children 2e6c9df8bea1
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
8771
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
1 " Vim Plugin: Edit the file with an existing Vim if possible
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
2 " Maintainer: Bram Moolenaar
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
3 " Last Change: 2016 Mar 28
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
4
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
5 " To use add ":packadd! editexisting" in your vimrc file.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
6
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
7 " This plugin serves two purposes:
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
8 " 1. On startup, if we were invoked with one file name argument and the file
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
9 " is not modified then try to find another Vim instance that is editing
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
10 " this file. If there is one then bring it to the foreground and exit.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
11 " 2. When a file is edited and a swap file exists for it, try finding that
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
12 " other Vim and bring it to the foreground. Requires Vim 7, because it
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
13 " uses the SwapExists autocommand event.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
14
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
15 " Function that finds the Vim instance that is editing "filename" and brings
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
16 " it to the foreground.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
17 func s:EditElsewhere(filename)
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
18 let fname_esc = substitute(a:filename, "'", "''", "g")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
19
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
20 let servers = serverlist()
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
21 while servers != ''
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
22 " Get next server name in "servername"; remove it from "servers".
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
23 let i = match(servers, "\n")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
24 if i == -1
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
25 let servername = servers
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
26 let servers = ''
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
27 else
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
28 let servername = strpart(servers, 0, i)
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
29 let servers = strpart(servers, i + 1)
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
30 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
31
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
32 " Skip ourselves.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
33 if servername ==? v:servername
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
34 continue
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
35 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
36
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
37 " Check if this server is editing our file.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
38 if remote_expr(servername, "bufloaded('" . fname_esc . "')")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
39 " Yes, bring it to the foreground.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
40 if has("win32")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
41 call remote_foreground(servername)
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
42 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
43 call remote_expr(servername, "foreground()")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
44
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
45 if remote_expr(servername, "exists('*EditExisting')")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
46 " Make sure the file is visible in a window (not hidden).
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
47 " If v:swapcommand exists and is set, send it to the server.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
48 if exists("v:swapcommand")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
49 let c = substitute(v:swapcommand, "'", "''", "g")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
50 call remote_expr(servername, "EditExisting('" . fname_esc . "', '" . c . "')")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
51 else
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
52 call remote_expr(servername, "EditExisting('" . fname_esc . "', '')")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
53 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
54 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
55
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
56 if !(has('vim_starting') && has('gui_running') && has('gui_win32'))
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
57 " Tell the user what is happening. Not when the GUI is starting
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
58 " though, it would result in a message box.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
59 echomsg "File is being edited by " . servername
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
60 sleep 2
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
61 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
62 return 'q'
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
63 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
64 endwhile
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
65 return ''
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
66 endfunc
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
67
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
68 " When the plugin is loaded and there is one file name argument: Find another
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
69 " Vim server that is editing this file right now.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
70 if argc() == 1 && !&modified
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
71 if s:EditElsewhere(expand("%:p")) == 'q'
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
72 quit
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
73 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
74 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
75
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
76 " Setup for handling the situation that an existing swap file is found.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
77 try
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
78 au! SwapExists * let v:swapchoice = s:EditElsewhere(expand("<afile>:p"))
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
79 catch
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
80 " Without SwapExists we don't do anything for ":edit" commands
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
81 endtry
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
82
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
83 " Function used on the server to make the file visible and possibly execute a
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
84 " command.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
85 func! EditExisting(fname, command)
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
86 " Get the window number of the file in the current tab page.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
87 let winnr = bufwinnr(a:fname)
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
88 if winnr <= 0
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
89 " Not found, look in other tab pages.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
90 let bufnr = bufnr(a:fname)
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
91 for i in range(tabpagenr('$'))
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
92 if index(tabpagebuflist(i + 1), bufnr) >= 0
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
93 " Make this tab page the current one and find the window number.
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
94 exe 'tabnext ' . (i + 1)
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
95 let winnr = bufwinnr(a:fname)
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
96 break
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
97 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
98 endfor
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
99 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
100
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
101 if winnr > 0
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
102 exe winnr . "wincmd w"
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
103 elseif exists('*fnameescape')
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
104 exe "split " . fnameescape(a:fname)
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
105 else
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
106 exe "split " . escape(a:fname, " \t\n*?[{`$\\%#'\"|!<")
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
107 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
108
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
109 if a:command != ''
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
110 exe "normal! " . a:command
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
111 endif
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
112
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
113 redraw
57cafbda13ad commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff changeset
114 endfunc