diffurcate.vim
diffurcate.vim copied to clipboard
Couldn't find pattern: ^diff --git \zs.\+\ze
as soon as I run this
git diff | vim - -R +Diffurcate
I get this error
Error detected while processing command line..function diffurcate#Run:
line 11:
Couldn't find pattern: ^diff --git \zs.\+\ze
Press ENTER or type command to continue
Could you post the output of git diff in that particular project, so I can try to figure out why the pattern doesn't match?
@AndrewRadev I get same error when running :Diffurcate in Vim:

Here is output of git diff:

@azamat-sharapov Could you post the full git output as text or attach it as a file, so I can run it locally? I could retype it from the image, but the error might be somewhere down below, or it might be some hidden characters, so ideally git diff > output.diff and uploading that here would be perfect.
@AndrewRadev here it is output.diff.zip (github doesn't allow .diff file upload, so I compressed it).
I see, this works fine for me, but I think I understand why it might not work now -- I think you might have set nomagic somewhere in your config. Could you try it out now?
@AndrewRadev didn't work, unfortunately..
Error detected while processing function diffurcate#Run:
line 11:
Couldn't find pattern: \m^diff --git \zs.\+\ze
Press ENTER or type command to continue
Here is my .vimrc:
.vimrc
set nocompatible " Disable vi-compatibility
set hidden
" Swap files out of the project root
set backupdir=~/.vim/backup//
set directory=~/.vim/swap//
syntax on
filetype plugin indent on
" Change <leader>
let mapleader = ","
let g:mapleader = ","
call plug#begin()
" color scheme
Plug 'morhetz/gruvbox'
Plug 'Shougo/context_filetype.vim'
" fuzzy search
Plug '/usr/local/opt/fzf'
Plug 'junegunn/fzf.vim'
" better in-buffer search
Plug 'junegunn/vim-slash'
" file tree
Plug 'scrooloose/nerdtree', { 'on': 'NERDTreeFind' }
Plug 'PhilRunninger/nerdtree-visual-selection'
" Plug 'jiangmiao/auto-pairs'
" Plug 'Raimondi/delimitMate'
" Plug 'michaeljsmith/vim-indent-object'
Plug 'urxvtcd/vim-indent-object'
Plug 'cohama/lexima.vim'
Plug 'tpope/vim-repeat'
Plug 'tpope/vim-surround'
Plug 'tpope/vim-eunuch'
Plug 'tpope/vim-unimpaired'
Plug 'tpope/vim-abolish'
Plug 'vim-scripts/Tabmerge'
Plug 'AndrewRadev/splitjoin.vim'
Plug 'chaoren/vim-wordmotion'
Plug 'svermeulen/vim-cutlass'
Plug 'vim-scripts/delview'
Plug 'vim-scripts/dbext.vim'
Plug 'ekalinin/Dockerfile.vim'
Plug 'AndrewRadev/diffurcate.vim'
" comment plugin
Plug 'tyru/caw.vim'
" multi cursor support
Plug 'mg979/vim-visual-multi', {'branch': 'master'}
" git plugin
Plug 'tpope/vim-fugitive'
" inserts end keyword for ruby
Plug 'tpope/vim-endwise'
" HTML/CSS plugin
Plug 'mattn/emmet-vim'
" ruby syntax highlighting, indentation, omnicompletion, etc.
Plug 'vim-ruby/vim-ruby'
" rails power tools
Plug 'tpope/vim-rails'
" lint engine
Plug 'dense-analysis/ale'
Plug 'neoclide/coc.nvim', {'branch': 'release'}
Plug 'exu/pgsql.vim'
Plug 'editorconfig/editorconfig-vim'
Plug 'othree/html5.vim'
Plug 'jvirtanen/vim-hcl'
Plug 'hashivim/vim-terraform'
Plug 'fatih/vim-go', { 'do': ':GoInstallBinaries' }
Plug 'posva/vim-vue'
Plug 'pangloss/vim-javascript'
Plug 'leafgarland/typescript-vim'
" Better JSON
Plug 'elzr/vim-json'
" github AI pairprogrammer
Plug 'github/copilot.vim'
" Plug 'joereynolds/vim-minisnip'
call plug#end()
" UI
set t_Co=256
set background=dark
let &t_8f = "\<Esc>[38;2;%lu;%lu;%lum"
let &t_8b = "\<Esc>[48;2;%lu;%lu;%lum"
set termguicolors
let g:gruvbox_contrast_dark='hard'
let g:gruvbox_hls_cursor='red'
let g:gruvbox_invert_selection=0
" let g:gruvbox_italic=0
colorscheme gruvbox
highlight Search cterm=underline
highlight SpecialKey ctermfg=grey guifg=grey25
set nocursorline
set showmode " always show what mode we're currently editing in
set showcmd " Show (partial) command in the status line
set nowrap " don't wrap lines
set tabstop=2 " a tab is two spaces
set smarttab
set tags=tags
set softtabstop=0 " when hitting <BS>, pretend like a tab is removed, even if spaces
set shiftwidth=3 " number of spaces to use for autoindenting
set shiftround " use multiple of shiftwidth when indenting with '<' and '>'
set backspace=indent,eol,start " allow backspacing over everything in insert mode
set autoindent " always set autoindenting on
set copyindent " copy the previous indentation on autoindenting
set number " always show line numbers
set incsearch " realtime search
set timeout timeoutlen=400 ttimeoutlen=0
set novisualbell " don't beep
set noerrorbells " don't beep
set autowrite " Save on buffer switch
set history=200
set nojoinspaces " no spaces on line join
set foldmethod=indent
set foldlevel=99
set scrolloff=5 " some padding on working line
set backupcopy=yes " otherwise webpack --watch won't work
set listchars=tab:>-,trail:~,extends:>,precedes:<,space:·
set nolist
set pastetoggle=<leader>I
set ignorecase
set smartcase " insensetive case when given text is all lowercase
set diffopt+=internal,algorithm:patience
set updatetime=300
" fix ctrl-up/down
map <ESC>[1;5A <C-Up>
map <ESC>[1;5B <C-Down>
map! <ESC>[1;5A <C-Up>
map! <ESC>[1;5B <C-Down>
" Fast saves
nmap <leader>w :w<cr>
" Fast quit
nmap <leader>q :q<cr>
" Easy escaping to normal model
imap jj <esc>
imap jk <esc>
" Easier window navigation
nmap <C-h> <C-w>h
nmap <C-j> <C-w>j
nmap <C-k> <C-w>k
nmap <C-l> <C-w>l
" Resize vsplit
nmap <C-v> :vertical resize +5<cr>
nmap 25 :vertical resize 40<cr>
nmap 50 <C-w>=
nmap 75 :vertical resize 120<cr>
" Create split below
nmap :sp :rightbelow sp<cr>
" When I forget sudo
cmap w!! w !sudo tee % >/dev/null
" autocmd cursorhold * set nohlsearch
" autocmd cursormoved * set hlsearch
" Make double-<Esc> clear search highlights
" nnoremap <silent> <Esc><Esc> <Esc>:nohlsearch<CR><Esc>
" Paste and indent
nnoremap <leader>p p=`]
" Quickly edit/reload the vimrc file
nmap <silent> <Leader>ev :e $MYVIMRC<CR>
nmap <silent> <Leader>sv :so $MYVIMRC<CR>
" Go to tab by number
noremap <leader>1 1gt
noremap <leader>2 2gt
noremap <leader>3 3gt
noremap <leader>4 4gt
noremap <leader>5 5gt
noremap <leader>6 6gt
noremap <leader>7 7gt
noremap <leader>8 8gt
noremap <leader>9 9gt
noremap <leader>0 :tablast<cr>
" Alternate file
nmap <Leader>6 <C-^>
" vim-cutlass
nnoremap x d
noremap x d
nnoremap xx dd
nnoremap X D
set statusline+=%#warningmsg#
set statusline+=%*
set statusline+=%F
" fix alt+n mapping in Vim CLI
if !has('gui_running')
exec "map \en <A-n>"
endif
" Auto save and load folds
augroup AutoSaveFolds
autocmd!
" view files are about 500 bytes
" bufleave but not bufwinleave captures closing 2nd tab
" nested is needed by bufwrite* (if triggered via other autocmd)
autocmd BufWinLeave,BufLeave,BufWritePost ?* nested silent! mkview!
autocmd BufWinEnter ?* silent! loadview
augroup end
" nerdtree toggle
let g:NERDTreeWinPos = 'right'
let g:NERDTreeWinSize=50
let g:NERDTreeMinimalMenu=1
map <Leader>t :NERDTreeFind<CR>
" fzf
nmap <Leader>b :Buffers<CR>
nnoremap <silent> <expr> <Leader><Leader> (expand('%') =~ 'NERD_tree' ? "\<c-w>\<c-w>" : '').":GFiles --cached --others --exclude-standard\<cr>"
nnoremap <silent> <Leader>ag :Ag <C-R><C-W><CR>
xnoremap <silent> <Leader>ag y:Ag <C-R>"<CR>
nnoremap <silent> <Leader>` :Marks<CR>
" query, ag options, fzf#run options, fullscreen
autocmd VimEnter *
\ command! -bang -nargs=* Ag
\ call fzf#vim#ag(<q-args>, '', { 'options': ['--bind', 'ctrl-a:select-all,ctrl-d:deselect-all'] }, <bang>0)
" minisnip
" let g:minisnip_trigger = '<C-j>'
" auto-pairs
" let g:AutoPairsFlyMode = 0
" coc
" inoremap <expr> <cr> pumvisible() ? "\<C-y>" : "\<C-g>u\<CR>"
" inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>"
" inoremap <silent><expr> <cr> pumvisible() ? coc#_select_confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
" inoremap <silent><expr> <NUL> coc#refresh()
inoremap <expr> <Tab> pumvisible() ? "\<C-n>" : "\<Tab>"
" inoremap <expr> <S-Tab> pumvisible() ? "\<C-p>" : "\<S-Tab>"
" Use tab for trigger completion with characters ahead and navigate.
" inoremap <expr> <Tab> coc#pum#visible() ? coc#pum#next(1) : CheckBackspace() ? "\<Tab>" : coc#refresh()
inoremap <expr> <S-TAB> coc#pum#visible() ? coc#pum#prev(1) : "\<C-h>"
" Make <CR> to accept selected completion item or notify coc.nvim to format
" <C-g>u breaks current undo, please make your own choice.
" inoremap <silent><expr> <C-Space> coc#pum#visible() ? coc#pum#confirm() : "\<C-g>u\<CR>\<c-r>=coc#on_enter()\<CR>"
nmap <silent> gd <Plug>(coc-definition)
nmap <silent> gy <Plug>(coc-type-definition)
nmap <silent> gi <Plug>(coc-implementation)
nmap <silent> gr <Plug>(coc-references)
function! CheckBackspace() abort
let col = col('.') - 1
return !col || getline('.')[col - 1] =~# '\s'
endfunction
" Github Copilot
imap <silent><script><expr> <C-J> copilot#Accept("\<CR>")
let g:copilot_no_tab_map = v:true
"\'coc-tsserver',
let g:coc_global_extensions = [
\'@yaegassy/coc-volar',
\'coc-tailwind-intellisense',
\'coc-go',
\]
" == ale
let g:ale_fix_on_save = 1
let g:ale_disable_lsp = 1
let g:ale_javascript_eslint_executable = 'eslint_d'
let g:ale_javascript_eslint_use_global = 1
let g:ale_fixers = ['prettier']
let g:ale_linters_explicit = 1
" == vim-wordmotion
let g:wordmotion_spaces = '_-.:'
let g:wordmotion_prefix = ''
"let g:wordmotion_mappings = {
"\ 'w' : '<C-w>',
"\ 'b' : '<C-b>',
"\ 'e' : '<C-e>',
"\ 'ge' : 'g<C-e>',
"\ 'aw' : 'a<C-w>',
"\ 'iw' : 'i<C-w>',
"\ }
" == pgsql syntax
let g:sql_type_default = 'pgsql'
" vim-json
let g:vim_json_warnings = 0
let g:vim_json_syntax_conceal = 0
runtime macros/matchit.vim
Hm, this is odd. I tried to set up your vimfiles locally, but I'm not getting that error (though I did have to remove CoC, it wasn't installing properly locally and it kept erroring out).
| A problem, but not that same error | Seems to work after the message |
|---|---|
![]() |
![]() |
There's definitely some problem, which I think has to do with the a/, b/ prefixes. Locally, when I git diff, I don't really get those. I wonder if it's a configuration of some kind. Do you know under what circumstances they show up?
I'll experiment some more in the coming days, see what I can figure out.
I've pushed another attempt at a fix. Could you try it out now, let me know if there's any difference?
Still no difference, unfortunately. My git version is 2.30.1 (Apple Git-130) and here is .gitconfig just in case:
.gitconfig
[color]
ui = true
[core]
filemode = false
editor = vim
[user]
email = [email protected]
name = "Azamat"
[alias]
st = status -sb
co = checkout
ll = log --oneline --all --decorate --graph
[push]
default = simple
[diff]
[merge "ours"]
driver = true
[init]
defaultBranch = main
Anything else I can provide?
Let's try this step by step. First, I'd like you to try directly searching for that pattern by pressing / to start a search and pasting \m^diff --git \zs.\+\ze . Note that it ends in a space. If that doesn't work, we can try removing some parts of it, see what exactly is going wrong.
If it does work, I'd like you to move to the start of the file with gg0 and then use : to enter command-line mode and paste echo search('\m^diff --git \zs.\+\ze ', 'Wc') and let me know what number it prints.
When searching, I got E486: Pattern not found: \m^diff --git \zs.\+\ze .
For the second command, I got 0.
Let's try a few one by one, see which ones hit. It's strange to me that they don't work, since I used your config as well:
\mdiff --git \zs.\+ze\m^diff --git .\+diff --git
Now that I think about it, I didn't ask which Vim/Neovim version you're using? I could try compiling that version in particular, maybe something subtle happened with the regexes that I didn't know about.

