I have some files with names as below
long-ordinary-filename-del-1.tex
long-ordinary-filename-del-2.tex
long-ordinary-filename-del-3.tex
Is it possible to define a command to cycle between these files? More concretely if I have long-ordinary-filename-2.tex
executing the command should take me to long-ordinary-filename-3.tex
and doing it again should give me long-ordinary-filename-1.tex
.
I would have posted what I have tried, but I have no idea how to search replace in commands. I know I can get the curent filename using :pwd
or expand('%:r')
.
EDIT: Using the solution from my previous question I was able to create this solution
" Swaps between similarly named files
func! IncrementDel(in)
let l:del = 1 + strcharpart(a:in, 4, 1)
if l:del > "3"
let l:del = 1
endif
return "del-" . l:del
endfunc
:nnoremap <localleader>nd o<Esc>"%p<S-V>:s/del-\d/\=IncrementDel(submatch(0))/<CR>:nohls<CR>dd:edit <C-r>"<CR>
- Pasting into the current file to switch files seems very barbaric, can this be avoided?