Loading ...
Sorry, an error occurred while loading the content.
 

vim conditional keymap when a tex file is open

Expand Messages
  • rudrab
    I am trying to make a keymap that will call latexmk when .tex is available (it would be better if .tex is the currently open and active buffer) ... when trying
    Message 1 of 3 , Jun 18 3:29 PM
      I am trying to make a keymap that will call latexmk when .tex is available (it would be better if .tex is the currently open and active buffer)

      I tried :

      :nnoremap <Leader>lw :if filereadable('*.tex')<cr>up!<cr>:!latexmk -pdf<cr>endif<cr>

      when trying to make latexmk -pdf run, but unfortunately, its just prompting those line in the window, and doing nothing like:

      ~
      :if filereadable('*.tex')
      : up!
      : :call Tex_RunLaTeX()
      : endif
      Press ENTER or type command to continue

      kindly help.

      (it will be great, as told, if this can be done when .tex is the currently open and active buffer.)

      --
      --
      You received this message from the "vim_use" maillist.
      Do not top-post! Type your reply below the text you are replying to.
      For more information, visit http://www.vim.org/maillist.php

      ---
      You received this message because you are subscribed to the Google Groups "vim_use" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
      For more options, visit https://groups.google.com/groups/opt_out.
    • Marc Weber
      vim file.tex ... then edit: ~/.vim/ftplugin/{the result of the echo command}.vim {the result of the echo command} may be tex or latex depending on which
      Message 2 of 3 , Jun 18 3:44 PM
        vim file.tex
        :echo &filetype

        then edit:
        ~/.vim/ftplugin/{the result of the echo command}.vim

        {the result of the echo command} may be "tex" or "latex" depending on
        which plugins you have installed.

        add something like this there to that file:

        noremap <buffer> <leader>lw :do thing

        <buffer> means the mapping will only active in the current buffer.

        Notes: filereadable does not accept glob patterns, use :h glob() first.
        To detect current extension use expand('%:e')

        Eventually you want to learn about quickfix, too. Simple example usage:

        exec 'set makeprg=mktex' | make %

        this runs mktex on the current file, then loads the error into the
        quickfix cycle.

        :h compiler
        :h errorformat

        may be useful, too.

        Because error formats from latex are hard to read by vim there are
        additional "translators" which run latex for you and print nice error
        locations instead. If you need more help about this use case write
        again.

        Marc Weber

        --
        --
        You received this message from the "vim_use" maillist.
        Do not top-post! Type your reply below the text you are replying to.
        For more information, visit http://www.vim.org/maillist.php

        ---
        You received this message because you are subscribed to the Google Groups "vim_use" group.
        To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
        For more options, visit https://groups.google.com/groups/opt_out.
      • rudrab
        ... while this is working(thanks), the problem is that, I have to make each ftplugin for each file type. It will be great if I could have if (buffer=*.tex)
        Message 3 of 3 , Jun 18 3:56 PM
          On Tuesday, June 18, 2013 11:44:04 PM UTC+1, MarcWeber wrote:

          >
          > then edit:
          >
          > ~/.vim/ftplugin/{the result of the echo command}.vim
          > {the result of the echo command} may be "tex" or "latex" depending on
          > which plugins you have installed.
          > add something like this there to that file:
          > noremap <buffer> <leader>lw :do thing
          >

          while this is working(thanks), the problem is that, I have to make each ftplugin for each file type.
          It will be great if I could have
          if (buffer=*.tex) <leader>lw :do thing
          in vimrc

          > Because error formats from latex are hard to read by vim there are
          > additional "translators" which run latex for you and print nice error
          > locations instead. If you need more help about this use case write
          > again.
          This is interesting. Please tell me more.

          --
          --
          You received this message from the "vim_use" maillist.
          Do not top-post! Type your reply below the text you are replying to.
          For more information, visit http://www.vim.org/maillist.php

          ---
          You received this message because you are subscribed to the Google Groups "vim_use" group.
          To unsubscribe from this group and stop receiving emails from it, send an email to vim_use+unsubscribe@....
          For more options, visit https://groups.google.com/groups/opt_out.
        Your message has been successfully submitted and would be delivered to recipients shortly.