├── .gitignore ├── README.md ├── autoload └── fuzzee.vim ├── doc └── fuzzee.txt └── plugin └── fuzzee.vim /.gitignore: -------------------------------------------------------------------------------- 1 | doc/tags 2 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | fuzzee.vim 2 | ========== 3 | 4 | Fuzzee.vim will tab-complete paths relative to the current working directory in 5 | Vim and also the current buffer for use with `:e[dit]`, `:E[xplore]`, and many 6 | other splitting options. It also ignores files, directories, and filetypes 7 | listed in the user-defined `wildignore` setting and has support for 8 | multi-directory globbing and custom-path mappings. 9 | 10 | 11 | Install 12 | ------- 13 | 14 | Install with [vim-pathogen](https://github.com/tpope/vim-pathogen) in your 15 | configured bundles folder. 16 | 17 | Or you can extract `fuzzee.vim` from `plugins/` and place it in your 18 | `~/.vim/plugins/` directory with the others. 19 | 20 | 21 | Usage 22 | ----- 23 | 24 | The `:F` command can be given any fuzzily-typed string that, when expanded, 25 | matches some filepath on your system. 26 | 27 | It accepts 3 different types of arguments: 28 | 29 | * Strings that expand to files relevant to the current buffer 30 | * The same but ones directly in the root of the current working directory 31 | * Absolute paths 32 | 33 | Let's give an example working directory and how `:F` can be used to navigate 34 | around it depending on what file you're currently viewing. Say the `cwd`, or 35 | current working directory, looks something like: 36 | 37 | **~/Dropbox/dev/project** 38 | 39 | app/ 40 | coffeescripts/ 41 | ****** application.coffee ****** 42 | models.coffee 43 | collections.coffee 44 | lib/ 45 | scripts.js 46 | public/ 47 | stylesheets/ 48 | sass/ 49 | css/ 50 | javascripts/ 51 | application.js 52 | models.js 53 | collections.js 54 | Cakefile 55 | 56 | First we'll use `:F` to get to the working directory from a new Vim session in 57 | your home directory. Any of the following are sufficient: 58 | 59 | :F ~/dr/de/pro " search for /Users/you/*d*r*/*d*e*/*p*r*o* 60 | :F `*dro*oje " globs for any *o*j*e* under /Users/you/*d*r*o*/**/ 61 | :F dr*project " search for any filepath *d*r**/*p*r*o*j*e*c*t* under the cwd 62 | 63 | Then `:FL` will change the local working directory to the project path or 64 | whatever directory the current buffer is in. `:FL` and `:FC` both accept 65 | arguments as well. 66 | 67 | A quick `:F */alcf` will glob the current working directory for `*a*l*c*f*` to 68 | edit `app/coffeescripts/application.coffee`. 69 | 70 | By hitting `:F `, Fuzzee.vim will show you everything in the current 71 | buffer's directory first but that's only if you give it no arguments. This will 72 | be everything in `app/coffeescripts/`. To edit `models.coffee`, type `:F md`. 73 | Remember, by default it will always refer first in relation to the current 74 | buffer and if no matches are found then show the current working directory. 75 | 76 | `:F ./` will search for anything in the current working directory. However, 77 | it's not always necessary. All of the following work to edit the `Cakefile` from 78 | the currently edited .coffee file: 79 | 80 | :F cak " search in the directory above the buffer for *c*a*k*. if 81 | " nothing is found, then search the current working directory. 82 | :F ./ckf " search in the current working directory for *c*k*f* 83 | :F */cake " glob for any filepath of *c*a*k*e* under the cwd 84 | 85 | Respectively, `:F ../` will search for anything in the directory above what 86 | you're currently editing. So at `app/coffeescripts/application.coffee`, then that 87 | will look in `app/coffeescripts`. 88 | 89 | To open directories quickly, Fuzzee.vim can also be invoked with no arguments or 90 | just `.` 91 | 92 | :F " opens up the directory above the current buffer 93 | :F . " open the current working directory 94 | 95 | Say you just `:quit` the application.coffee file in vim but you want to open it 96 | back up quickly. 97 | 98 | :FB applcof " open a buffer with matching fuzzy string "*a*p*p*l*c*o*f*" 99 | " either as a relation to the cwd or full path 100 | 101 | The fuzzy-expansion works for any filepath on your system no matter where you 102 | are but it can always backtrace to the current working directory as well. 103 | Primarily, it searches in relation to what you're currently viewing. 104 | 105 | 106 | Commands 107 | -------- 108 | 109 | * `:F ` - open a fuzzy-string filepath 110 | * `:FS` - open up in a split 111 | * `:FV` - open in a vertical split 112 | * `:FT` - open in a new tab 113 | * `:FL` - change local working directory 114 | * `:FC` - change working directory 115 | * `:FB` - open a hidden or switch to an active buffer 116 | 117 | 118 | Path Mappings 119 | -------- 120 | Fuzzee.vim can be used for exploring common project filepaths and directories 121 | quickly with a cmapping. For instance, to match any javascripts in your `public` 122 | directory, try out the following: 123 | 124 | ```vim 125 | set wcm= " this is just a way to map completion 126 | FuzzeeMap ,js javascript 127 | FuzzeeMap ,cs css 128 | FuzzeeMap ,st specs/spec 129 | ``` 130 | 131 | How this works is that you'd type in `:F mod,js` which would then expand and 132 | tab-complete to `:F javascript/model.js` or whatever file matches `*m*o*d*`. If 133 | you just want to explore the directory, `:F ,js` will show a menu of files in 134 | the javascript directory. 135 | 136 | If you have multiple directories of the same name, remember you can specify from 137 | the root with a prepended `./` as `./javascript`. Lastly, if you just want to 138 | glob down from a certain path in your project you can use a mapping like 139 | `FuzzeeMap ,js app/javascript*` which will look through all folders from that 140 | starting point. 141 | 142 | To set default mappings in your `vimrc`, use the following: 143 | 144 | ```vim 145 | call fuzzee#map(',ac', 'app/coffeescripts') 146 | call fuzzee#map(',js', 'javascript') 147 | call fuzzee#map(',cs', 'css') 148 | ``` 149 | 150 | Make sure to read the next section for recommended wildmenu options. 151 | 152 | 153 | Tips 154 | ---- 155 | 156 | Some recommended vimrc settings: 157 | 158 | ```vim 159 | nnoremap f :F 160 | nnoremap t :F */ 161 | set wildmode=list:longest,full 162 | set wildmenu 163 | set wildignore+= 164 | \*.png,*.jpg,*.pdf, 165 | \CVS,SVN, 166 | \" more files to ignore here 167 | set switchbuf=usetab 168 | ``` 169 | 170 | * Vim has a global working directory `:cd` and a local to window (that includes 171 | splits) working directory `:lcd`. Use these for making project paths relative 172 | as `app/dir` and not absolute like `/Users/foo/dev/app/dir`. 173 | 174 | * Hitting `` with any expanded path deletes back to the last word - use to 175 | move up directories quickly. 176 | 177 | * The `'switchbuf'` setting allows the `:FB` command to find files in other tabs or 178 | splits with a matching fuzzy-name. If the buffer is hidden (a file that was `:q`) 179 | then the command will just open the buffer in the current window. 180 | 181 | Links 182 | ----- 183 | 184 | [GitHub Repo](http://github.com/mattsa/vim-fuzzee/) 185 | [vim.org](http://www.vim.org/scripts/script.php?script_id=3716) 186 | [Github Author](http://github.com/mattsa) 187 | [Twitter](http://twitter.com/mattsa) 188 | -------------------------------------------------------------------------------- /autoload/fuzzee.vim: -------------------------------------------------------------------------------- 1 | " for use with cmap to either navigate to a directory or tab-complete the file 2 | " example: FuzzeeMap ,js app/javascript call fuzzee#map(',js','app/javascript') 3 | " :F ,js => :F javascript :F foo,js => :F javascript/foo.js 4 | function! fuzzee#expand(path) 5 | let l:fCmd = matchstr(getcmdline(), '^F\w\=\s') 6 | let l:fArg = matchstr(getcmdline(), '^F\w\=\s\zs.*$') 7 | let l:extension = '' 8 | if a:path =~ '\/$' || a:path =~ '\*$' 9 | let l:path = a:path 10 | elseif a:path =~ '!\w\+$' 11 | let l:path = matchstr(a:path, '^.\{-}\ze!') 12 | let l:extension = matchstr(a:path, '!\zs\w\+$') 13 | else 14 | let l:path = a:path . '/' 15 | endif 16 | return l:fCmd . (l:fArg =~ '^$' ? l:path . l:extension : 17 | \ l:path . l:fArg . l:extension) 18 | endfunction 19 | 20 | function! fuzzee#map(map, path, ...) 21 | exe 'cmap' a:map . " efuzzee#expand('" . a:path . "')" . nr2char(&wcm) 22 | endfunction 23 | 24 | command! -complete=file -nargs=+ FuzzeeMap :call fuzzee#map() 25 | -------------------------------------------------------------------------------- /doc/fuzzee.txt: -------------------------------------------------------------------------------- 1 | *fuzzee.vim* Fuzzy expansions for :e and :E 2 | 3 | *fuzzee-author* 4 | Author: Matt Sacks 5 | Copyright: Matt Sacks (c) 6 | License: Same terms as Vim itself (see |license|) 7 | 8 | This plugin is works with Vim version 7.0 and higher. 9 | 10 | 11 | INTRODUCTION *fuzzee* 12 | 13 | Install fuzzee.vim into ~/.vim/plugins/ and fuzzee.txt into 14 | ~/.vim/doc/ or use vim-pathogen and install into your designated 15 | bundles folder. 16 | 17 | 18 | USAGE *fuzzee-usage* 19 | 20 | Fuzzee.vim has different commands but they all accept the same type of 21 | fuzzy-name argument. Any arg to |:F| can be a typed string that, when 22 | expanded, returns some filename or directory on your system. For example, 23 | |:F| ~/lo/p/t/f would return '/Users/you/long/path/to/foo.txt' 24 | |:F| ~/long*foot also works as well 25 | 26 | You don't always have to type in a full path - arguments can be 27 | relative paths instead of absolute ones. Say you're currently editing a file 28 | in '~/long/path' called 'bar.txt' and you wanted to edit the 'foo.txt' from 29 | the previous example. Since it's in a directory below the current one, use 30 | |:F| to/fo to reach 'to/foo.txt' 31 | |:F| *foot is a globbed version 32 | 33 | 34 | ARGUMENTS *fuzzee-arguments* 35 | 36 | This plugin can glob for 3 types of fuzzy-typed arguments: 37 | * Those relative to the current buffer 38 | * Arguments relative to the current working directory 39 | * Absolute paths 40 | 41 | :F [args] Fuzzy-complete any filepath relative to the 42 | current buffer, the working directory, or any 43 | absolute path and execute 'edit'. 44 | 45 | :F ../[args] Fuzzy-complete any args relative to the 46 | directory above the current buffer. 47 | 48 | :F ./[args] Fuzzy-complete any args relative to the 49 | current working directory. 50 | 51 | :F [directory] Fuzzy-complete any absolute directory with 52 | ~ ` or / as it's first character or any 53 | relative directory and execute 'edit', 54 | opening up the the explorer. If the last 55 | character is / then open the first match 56 | inside that directory. 57 | 58 | :F ` 59 | :F ~ Complete starting at the user's '$HOME' 60 | directory. 61 | 62 | :F / Complete starting at the root directory. 63 | 64 | *fuzzee-globbing* 65 | :F * Look for anything after * in any directory 66 | under the current buffer. 67 | 68 | :F */ Look for anything after */ in any directory 69 | under the current working directory. 70 | 71 | 72 | 73 | COMMANDS *fuzzee-commands* 74 | 75 | Each of these commands perform a different task but they all execute on the 76 | same type of arguments. All of these accept any relative, absolute, or globbed 77 | filenames and directories for which to open quickly. If blank, they open up 78 | the explorer which is netrw by default. You can use |:F| from the explorer as 79 | well as the arguments by default are relative to the current working directory. 80 | 81 | *fuzzee-:F* 82 | :F With no arguments, open up the directory above 83 | the current buffer. Otherwise, this tab 84 | completes to the current buffer's 85 | directory. However, you can give it any 86 | fuzzy name of a file or pathname defined in 87 | the arguments section above. 88 | 89 | :F . Open the current working directory. 90 | 91 | *fuzzee-:FS* 92 | :FS Open in a split. With no arguments, this 93 | splits to the directory above the current 94 | buffer. 95 | 96 | *fuzzee-:FV* 97 | :FV Open in a vertical split. With no arguments, 98 | this splits vertically to the directory above 99 | the current buffer. 100 | 101 | *fuzzee-:FT* 102 | :FT Open in a new tab. With no arguments, this 103 | opens to the directory above the current 104 | buffer. 105 | 106 | *fuzzee-:FL* 107 | :FL Changes local directory |:lcd| to a given 108 | argument. 109 | 110 | *fuzzee-:FC* 111 | :FC Changes working directory |:cd| to a given 112 | argument. 113 | 114 | *fuzzee-:FB* 115 | :FB Search the 'buflist' for a buffer using a 116 | fuzzy string in any part of it's relative or 117 | full path. Will use the |:sb| command if your 118 | 'switchbuf' setting isn't set to the default 119 | value (""). 120 | 121 | :FuzzeeMap *FuzzeeMap* 122 | Create a 'cmap' that will use the 'wcm' to 123 | auto-complete a mapping inside a specific 124 | path, or if given no argument, insert that 125 | path. Like everything else, uses 'wildmode'. 126 | 127 | 128 | FUNCTIONS *fuzzee-functions* 129 | 130 | Functions defined in autoload/fuzzee.vim can be used as an interface to set 131 | preferences to the Fuzzee plugin directly inside of your 'vimrc'. 132 | 133 | fuzzee#map('cmap', 'path') *fuzzee-map* 134 | Creates a custom 'cmap' exactly the same as 135 | |FuzzeeMap| but the passed arguments must be 136 | surrounded in single-quotes. 137 | 138 | 139 | TIPS *fuzzee-tips* 140 | 141 | Fuzzee.vim can be used to navigate common paths and files quickly. If your 142 | typing out paths to filesnames quite often, mappings can shortcut them for 143 | you. Remember - these paths are shorter if they are local to the current 144 | working directory or buffer. See 'lcd' on how to configure this and use 145 | |:FL| to navigate quickly. 146 | 147 | It is highly recommended you do not use the 'autochdir' option. That 148 | changes the 'cwd' to always refer to the current buffer, losing any track 149 | of a "working directory" for your projects. |:F| works best when used 150 | against buffers and the 'cwd'. 151 | 152 | Globbing is only as fast the more information that you give it. With each 153 | character before and after * then Vim will be able to find your file 154 | more quickly. 155 | 156 | The |:FB| command can be helpful for finding files in other tabs or a 157 | file that has been recently opened in the current Vim session. Use the 158 | 'switchbuf' setting to navigate open and hidden files. 159 | 160 | FuzzeeMap is very useful for navigating to the same directories without 161 | having to type much of the path. 162 | 163 | See the README for more information, examples, and tricks. 164 | 165 | 166 | ABOUT *fuzzee-about* 167 | 168 | This plugin is used to leverage 'edit' with fuzzy-completion both local to 169 | the current buffer, the current working directory, and any specified path. 170 | It also uses any 'wildignore' settings for faster globbing with * 171 | 172 | For the most up to date development version or to report any inevitable bugs, 173 | please visit: 174 | 175 | http://github.com/mattsacks/vim-fuzzee 176 | 177 | vim:tw=78:et:ft=help:norl: 178 | -------------------------------------------------------------------------------- /plugin/fuzzee.vim: -------------------------------------------------------------------------------- 1 | " fuzzee.vim - Fuzzy expansions for :e and :E 2 | " Author: Matt Sacks 3 | " Version: 1.0 4 | " Last Modified: 02/20/12 5 | 6 | if exists('g:loaded_fuzzee') || v:version < 700 7 | finish 8 | endif 9 | let g:loaded_fuzzee = 1 10 | 11 | " utility {{{1 12 | function! s:gsub(str,pat,rep) abort 13 | return substitute(a:str,'\v\C'.a:pat,a:rep,'g') 14 | endfunction 15 | 16 | " sort by shortest pathname first 17 | function! s:sortfile(f1, f2) 18 | return a:f1 == a:f2 ? 0 : len(a:f1) > len(a:f2) ? 1 : -1 19 | endfunction 20 | 21 | " return the sorted list with either the tail of the relative path 22 | " or the full pathname 23 | function! s:sortlist(ls, tail) 24 | if a:tail 25 | return sort(map(copy(split(a:ls, "\n")), 'fnamemodify(v:val, ":t")'), 's:sortfile') 26 | else 27 | return sort(split(a:ls, "\n"), 's:sortfile') 28 | endif 29 | endfunction 30 | 31 | " remove the trailing '/' and prepended './' to the cwd path 32 | function! s:filterglob(ls, cwd) 33 | let ls = substitute(a:ls, a:cwd.'/', '', 'g') 34 | return substitute(ls, '\.\/', '', 'g') 35 | endfunction 36 | " END utility }}}1 37 | 38 | " fuzzyglob {{{1 39 | function! s:fuzzglob(arg,L,P) 40 | let s:head = '' 41 | if &ft == 'netrw' && expand('%') =~ '^$' 42 | let dir = fnameescape(b:netrw_curdir) 43 | let updir = fnameescape(fnamemodify(b:netrw_curdir, ':h')) 44 | else 45 | let dir = fnameescape(expand('%')) 46 | let updir = fnameescape(expand('%:h')) 47 | endif 48 | let cwd = fnameescape(getcwd()) 49 | 50 | " before fuzzy-expansion {{{2 51 | if a:arg =~ '^\s*$' 52 | if &ft == 'netrw' 53 | if dir =~ '^$' 54 | return s:sortlist(globpath('/', '*'), 1) 55 | else 56 | return s:sortlist(globpath(dir, '*'), 1) 57 | endif 58 | elseif dir =~ '^$' 59 | return s:sortlist(globpath(cwd, '*'), 1) 60 | else 61 | return s:sortlist(globpath(updir, '*'), 1) 62 | endif 63 | endif 64 | 65 | let f = a:arg 66 | 67 | if a:arg =~ '^\/$' 68 | return s:sortlist(globpath('/', '*'), 0) 69 | endif 70 | 71 | if a:arg =~ '^\.\/' 72 | let s:head = '.' 73 | endif 74 | 75 | " expand the full path if given a relative '../' argument and prepend 76 | " to the :F argument 77 | if a:arg =~ '^\.\.\/' 78 | let dots = matchlist(a:arg, '\(\.\.\/\)\+')[0] 79 | let path = matchlist(a:arg, '\%(\.\.\/\)\+\(.*\)$')[1] 80 | if &ft == 'netrw' 81 | let f = fnamemodify(dir.'/'.dots, ':p') 82 | else 83 | let f = fnamemodify(updir.'/'.dots, ':p') 84 | endif 85 | let f = f . path 86 | endif 87 | " END fuzzy-expansion }}}2 88 | 89 | " fuzzy-glob from Tim Pope's utilities 90 | let f = s:gsub(s:gsub(f,'[^/.]','[&]*'),'%(/|^)\.@!|\.','&*') 91 | 92 | if a:arg =~ '^\*\/' 93 | let f = substitute(f, '^\*[\*\]\*', '**', '') 94 | endif 95 | let f = s:gsub(f, '\*[\*\]\*', '**/*') 96 | let f = substitute(f, '\*\[[~`]\]', '$HOME', '') 97 | let tail = fnamemodify(f, ':t') 98 | 99 | " its globbering time {{{2 100 | if f == tail && &ft != 'netrw' 101 | let ls = globpath(updir, f) 102 | elseif &ft == 'netrw' 103 | if s:head !~ '^$' 104 | let ls = globpath(cwd, tail) 105 | elseif f =~ '^\/' && f !~ '\/*$' 106 | let ls = globpath('/', tail) 107 | elseif f =~# '^$HOME' 108 | let ls = s:gsub(globpath(f, ''), '/$', '') 109 | elseif dir =~ '^\/$' 110 | let ls = globpath('/', f) 111 | elseif a:arg =~ '^*\/' 112 | let ls = globpath(cwd, f) 113 | let ls = s:filterglob(ls, cwd) 114 | elseif a:arg =~ '^*' 115 | let ls = globpath(dir, f) 116 | let ls = s:filterglob(ls, cwd) 117 | else 118 | let ls = globpath(dir, f) 119 | endif 120 | else 121 | if s:head !~ '^$' 122 | let f = substitute(f, '^\.\*', '\.', '') 123 | let ls = globpath(cwd, f) 124 | elseif a:arg =~ '^\*\/' 125 | let ls = globpath(cwd, f) 126 | elseif a:arg =~ '^\*' 127 | let s:head = updir 128 | let ls = globpath(updir, f) 129 | else 130 | let ls = globpath(updir, f) 131 | endif 132 | let ls = s:filterglob(ls, cwd) 133 | endif 134 | 135 | " return the globbed files {{{2 136 | if len(ls) == 0 && tail !~ '\.' 137 | " defer globbing if not necessary 138 | if s:head !~ '^$' 139 | echomsg 'not found' 140 | return '' 141 | elseif len(glob(f)) == 0 142 | echomsg 'not found' 143 | return '' 144 | endif 145 | return s:sortlist(glob(f), 0) 146 | elseif len(ls) == 0 147 | return s:sortlist(glob(f), 0) 148 | else 149 | if &ft == 'netrw' && f == tail && s:head =~ '^$' 150 | let s:head = fnamemodify(split(ls, "\n")[0], ':h') 151 | elseif f == tail && &ft != 'netrw' && s:head =~ '^$' 152 | let s:head = updir 153 | endif 154 | if f == tail 155 | return s:sortlist(ls, 1) 156 | else 157 | return s:sortlist(ls, 0) 158 | endif 159 | endif 160 | endfunction 161 | " END fuzzyglob }}}1 162 | 163 | " the F command {{{1 164 | function! s:F(cmd, ...) 165 | let cmds = {'E': 'edit', 'S': 'split', 'V': 'vsplit', 'T': 'tabedit', 166 | \'L': 'lcd', 'C': 'cd'} 167 | let cmd = cmds[a:cmd] 168 | if &ft == 'netrw' && expand('%') =~ '^$' 169 | let dir = substitute(fnameescape(b:netrw_curdir), '\(.\)/$', '\1', '') 170 | let updir = substitute(fnameescape(fnamemodify(b:netrw_curdir, ':h')), '\(.\)/$', '\1', '') 171 | else 172 | let dir = substitute(fnameescape(expand('%')), '\(.\)/$', '\1', '') 173 | let updir = substitute(fnameescape(expand('%:h')), '\(.\)/$', '\1', '') 174 | endif 175 | let cwd = substitute(fnameescape(getcwd()), '\(.\)/$', '\1', '') 176 | 177 | if a:0 == 0 178 | if &ft == 'netrw' 179 | execute 'silent! ' cmd dir 180 | else 181 | execute 'silent! ' cmd updir 182 | endif 183 | return '' 184 | endif 185 | 186 | if a:1 =~ '^\.$' 187 | execute 'silent! '.cmd cwd 188 | return '' 189 | endif 190 | 191 | let f = s:fuzzglob(a:1, '', '') 192 | " remove the prepended '/' if globbed from the root 193 | if (s:head =~ '^\.' && f[0][0] == '/') || s:head =~ '^\/$' 194 | let s:head = '' 195 | endif 196 | if len(f) == 0 197 | return '' 198 | elseif s:head !~ '^$' 199 | return 'silent '.cmd.' '.fnameescape(s:head.'/'.f[0]) 200 | else 201 | return 'silent '.cmd.' '.fnameescape(f[0]) 202 | endif 203 | if &ft != 'netrw' 204 | return 'silent lcd' fnameescape(getcwd()) 205 | endif 206 | endfunction 207 | " END the F command }}}1 208 | 209 | " fuzzee-buffer {{{1 210 | function! s:buffglob(arg,L,P) 211 | let buffers = [] 212 | for b in range(1, bufnr('$')) 213 | if bufexists(b) && buflisted(b) == 1 214 | call add(buffers, bufname(b)) 215 | endif 216 | endfor 217 | if a:arg =~ '^$' 218 | return buffers 219 | endif 220 | 221 | let b = s:gsub(s:gsub(a:arg,'[^/.\>]','[&].*'),'%(/|^)\.@!|\.','&') 222 | let b = s:gsub(b, '\*\[ \]\*', '*') 223 | 224 | return filter(buffers, 'v:val =~ b') 225 | endfunction 226 | 227 | function! s:FB(...) 228 | if a:0 == 0 229 | return 'silent b '.bufname('#') 230 | endif 231 | 232 | let f = s:buffglob(a:1, '', '') 233 | if len(f) == 0 234 | echomsg 'no buffers found' 235 | return '' 236 | endif 237 | let s = '' 238 | 239 | if &switchbuf !~ '^$' 240 | for i in range(1, tabpagenr('$')) 241 | if index(tabpagebuflist(i), bufnr(f[0])) != -1 242 | let s = 's' 243 | break 244 | endif 245 | endfor 246 | endif 247 | return 'silent '.s.'b '.f[0] 248 | endfunction 249 | " END fuzzee-buffer }}}1 250 | 251 | command! -nargs=? -bar -complete=customlist,s:fuzzglob F :execute s:F('E', ) 252 | command! -nargs=? -bar -complete=customlist,s:fuzzglob FS :execute s:F('S', ) 253 | command! -nargs=? -bar -complete=customlist,s:fuzzglob FV :execute s:F('V', ) 254 | command! -nargs=? -bar -complete=customlist,s:fuzzglob FT :execute s:F('T', ) 255 | command! -nargs=? -bar -complete=customlist,s:fuzzglob FL :execute s:F('L', ) 256 | command! -nargs=? -bar -complete=customlist,s:fuzzglob FC :execute s:F('C', ) 257 | command! -nargs=? -bar -complete=customlist,s:buffglob FB :execute s:FB() 258 | --------------------------------------------------------------------------------