Mercurial > vim
annotate runtime/pack/dist/opt/editexisting/plugin/editexisting.vim @ 29202:b6c284c1f095 v8.2.5120
patch 8.2.5120: searching for quotes may go over the end of the line
Commit: https://github.com/vim/vim/commit/2f074f4685897ab7212e25931eeeb0212292829f
Author: Bram Moolenaar <Bram@vim.org>
Date: Sat Jun 18 11:22:40 2022 +0100
patch 8.2.5120: searching for quotes may go over the end of the line
Problem: Searching for quotes may go over the end of the line.
Solution: Check for running into the NUL.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 18 Jun 2022 12:30:05 +0200 |
parents | 2e6c9df8bea1 |
children | 71cbad0921c9 |
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 |
29198
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
3 " Last Change: 2022 Jun 17 |
8771
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. |
29198
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
38 try |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
39 if remote_expr(servername, "bufloaded('" . fname_esc . "')") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
40 " Yes, bring it to the foreground. |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
41 if has("win32") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
42 call remote_foreground(servername) |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
43 endif |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
44 call remote_expr(servername, "foreground()") |
8771
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
45 |
29198
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
46 if remote_expr(servername, "exists('*EditExisting')") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
47 " Make sure the file is visible in a window (not hidden). |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
48 " If v:swapcommand exists and is set, send it to the server. |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
49 if exists("v:swapcommand") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
50 let c = substitute(v:swapcommand, "'", "''", "g") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
51 call remote_expr(servername, "EditExisting('" . fname_esc . "', '" . c . "')") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
52 else |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
53 call remote_expr(servername, "EditExisting('" . fname_esc . "', '')") |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
54 endif |
8771
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
55 endif |
29198
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
56 |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
57 if !(has('vim_starting') && has('gui_running') && has('gui_win32')) |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
58 " Tell the user what is happening. Not when the GUI is starting |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
59 " though, it would result in a message box. |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
60 echomsg "File is being edited by " . servername |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
61 sleep 2 |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
62 endif |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
63 return 'q' |
8771
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
64 endif |
29198
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
65 catch /^Vim\%((\a\+)\)\=:E241:/ |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
66 " Unable to send to this server, ignore it. |
2e6c9df8bea1
patch 8.2.5118: MS-Windows: sending a message to another Vim may hang
Bram Moolenaar <Bram@vim.org>
parents:
8771
diff
changeset
|
67 endtry |
8771
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
68 endwhile |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
69 return '' |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
70 endfunc |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
71 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
72 " 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
|
73 " 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
|
74 if argc() == 1 && !&modified |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
75 if s:EditElsewhere(expand("%:p")) == 'q' |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
76 quit |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
77 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
78 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
79 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
80 " 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
|
81 try |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
82 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
|
83 catch |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
84 " 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
|
85 endtry |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
86 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
87 " 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
|
88 " command. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
89 func! EditExisting(fname, command) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
90 " 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
|
91 let winnr = bufwinnr(a:fname) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
92 if winnr <= 0 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
93 " Not found, look in other tab pages. |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
94 let bufnr = bufnr(a:fname) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
95 for i in range(tabpagenr('$')) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
96 if index(tabpagebuflist(i + 1), bufnr) >= 0 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
97 " 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
|
98 exe 'tabnext ' . (i + 1) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
99 let winnr = bufwinnr(a:fname) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
100 break |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
101 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
102 endfor |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
103 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
104 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
105 if winnr > 0 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
106 exe winnr . "wincmd w" |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
107 elseif exists('*fnameescape') |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
108 exe "split " . fnameescape(a:fname) |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
109 else |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
110 exe "split " . escape(a:fname, " \t\n*?[{`$\\%#'\"|!<") |
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 if a:command != '' |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
114 exe "normal! " . a:command |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
115 endif |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
116 |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
117 redraw |
57cafbda13ad
commit https://github.com/vim/vim/commit/cf2d8dee5117b9add3a3f5fc91b3569437e7d359
Christian Brabandt <cb@256bit.org>
parents:
diff
changeset
|
118 endfunc |