vim - Using '#' in bash command in .vimrc -


i'd create new command compiles current *.tex file , shows in pdf viewer (i'm using osx due use preview). here attempt:

autocmd bufreadpost,bufwritepost *.tex nmap <leader>b :!temp=% && pdf=${temp:0: ${#temp}-4 } && echo $temp && "/usr/texbin/pdflatex" -synctex=1 -interaction=nonstopmode % && open $pdf && unset temp pdf<cr> 

temp file name of mit *.tex file.

pdf file name of *.pdf.

however when execute following error message:

499: empty file name '%' or '#', works ":p:h" 

is there different method shorten string without using '#'?

solution:

autocmd bufreadpost,bufwritepost *.tex nmap <leader>b :!pdf="%<.pdf" && "/usr/texbin/pdflatex" -synctex=1 -interaction=nonstopmode "%" && open "$pdf" && unset pdf<cr> 

why not use error message's suggestion , set pdf in vimscript instead of in shell? replace

pdf=${temp:0: ${#temp}-4 } 

with

pdf=%< 

or even

pdf=%<.pdf 

to give proper extension.


Comments

Popular posts from this blog

ruby on rails - Is it the correct way to implement belongs_to relation with factory girl? -

geolocation - Windows Phone 8 - Keeping background location tracking active beyond four hours -

Uncaught TypeError: Cannot read property 'parentNode' of null javascript -