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

14189Opening LaTeX .tex files in MacVim / Mavericks

Expand Messages
  • jj
    May 29 1:45 PM
    • 0 Attachment
      Hi Everyone,
      I’ve been using MacVim for quite some time and after upgrading to Mavericks, I realized I needed a new version for that system. I was able to download and install a snapshot release of version 7.4 which works on Mavericks when opening smaller files but, it seems, not larger ones. Specifically, e.g., if I try to open a somewhat larger .tex file (152Kb) the app opens a blank window and stops. It does however work on smaller .tex files - I tested on an extremely small text (.tex) file with only 3 lines. The smaller file open and the LaTeX plugin worked.

      Note: I’m only assuming the issue is related to file size, I’m sure I could be wrong about that.

      Bjorn suggested that it may be an issue with a plugin and that I should apply the trouble shooting guide steps.

      The first thing I did was to rename/disable my .vimrc. After doing this the larger file opened quickly w/o a problem however the LaTeX plugin does not
      show up.

      It seems therefore that the problem is with my .vimrc but not related to the LaTeX plugin (underscore seems).

      I've added my .vimrc and was wondering if anyone sees an obvious problem. Note this worked Ok before upgrading to Mavericks though even then
      the bigger .tex file seemed to load a bit slow.

      Many thanks & take care,
      Joe Retzer


      " ------------------------------- cut here --------------------------



      REQUIRED. This makes vim invoke Latex-Suite when you open a tex file.

      set nocompatible
      syntax enable
      filetype indent on

      filetype plugin on

      " IMPORTANT: win32 users will need to have 'shellslash' set so that latex
      " can be called correctly.
      " set shellslash

      " Set font and font size
      "set gfn=Monaco:h16

      " IMPORTANT: grep will sometimes skip displaying the file name if you
      " search in a singe file. This will confuse Latex-Suite. Set your grep
      " program to always generate a file-name.
      set grepprg=grep\ -nH\ $*

      " OPTIONAL: This enables automatic indentation as you type.
      filetype indent on

      " OPTIONAL: Starting with Vim 7, the filetype of empty .tex files defaults to
      " 'plaintex' instead of 'tex', which results in vim-latex not being loaded.
      " The following changes the default filetype back to 'tex':
      let g:tex_flavor='latex'

      " Make \lv (mac-LaTeX) open the pdf in preview
      let g:Tex_ViewRule_pdf = 'open -a Preview'

      " R compiling options

      let g:r_macvim_RSend = '<D-r>'
      let g:r_macvim_RChgWorkDir = '<D-d>'
      let g:r_macvim_RComment = '<D-3>'
      let g:r_macvim_RSource = '<D-R>'


      "=============================================================================
      " File: R.vim
      " Author: Vincent Nijs ()
      " Last Change: Mon Dec 3 15:28:23 CST 2007
      " Version: 0.01
      "=============================================================================

      " map <F3> to run the R script, vim will wait for the output
      map <buffer> <F3> :call RunRProgram("selectedlines")<CR><CR>
      imap <buffer> <F3> <ESC>:call RunRProgram("selectedlines")<CR><CR>a

      " map <F4> to run the R script, vim will wait for the output
      map <buffer> <F4> :call RunRProgram("quick")<CR><CR>
      imap <buffer> <F4> <ESC>:call RunRProgram("quick")<CR><CR>a

      " map <F5> to run the R script, long mode. You will see a tail of the output file
      map <buffer> <F5> :call RunRProgram("long")<CR><CR>
      imap <buffer> <F5> <ESC>:call RunRProgram("long")<CR><CR>a

      " map <F6> to run the Ruby script, vim will wait for the output
      map <buffer> <F6> :call OpenROutput()<CR>
      imap <buffer> <F6> <ESC>:call OpenROutput()<CR>a

      " comment lines in/out
      noremap <buffer> mc :call RToggleCommentify()<CR>j^

      " highlighting the braces
      syn match RBraces "[\{\}\[\]\(\)]"
      hi RBraces ctermfg=9 guifg=orange

      " -----------------------------------------------------------------------------
      " R functions
      " -----------------------------------------------------------------------------
      function! RunRProgram(mode) range " {{{
      " write buffer
      execute 'w!'

      " get the name of the current buffer, plus the full path
      let codeBuffer = expand("%:p")

      " set the name for the output buffer
      let outputBuffer = expand("%:r:h").'.rout'

      if a:mode == "selectedlines"
      " sending selected lines to interactive R application
      let command = join(getline(a:firstline,a:lastline),"\\n")
      let command = substitute(command,"\"","\\\\\"","g")
      let command = substitute(command,"\'","\\\\\"","g")
      call system("osascript -e 'tell application \"R\" to cmd \"" .command. "\"'")

      elseif a:mode == "quick"
      " opening a buffer for the output
      execute 'e! ' outputBuffer

      " clearing contents of the output buffer
      execute '%d'

      " Only one window visible
      execute 'only'

      " run the R program
      execute '!R --save < ' codeBuffer ' > ' outputBuffer ' 2>&1'
      "call system('R --save < ' codeBuffer ' > ' outputBuffer ' 2>&1')


      " open the changed file
      execute 'e! ' outputBuffer
      execute 'normal gg'

      " if there are errors in the output file jump to the first one
      if search(".rb:[0-9]\*:","W") == 0
      execute 'normal G'
      endif

      elseif a:mode == "long"

      let batchFileBuffer = "~/myVimFiles/vimSwap/rVim.bat"
      execute 'e! ' batchFileBuffer
      " clearing contents of buffer
      execute '%d'
      " creating a command file that can be run externally using the 'tee' command
      call append(0, 'R --save < ' .codeBuffer. ' > ' .outputBuffer. ' 2>&1')

      execute 'w ' batchFileBuffer
      execute '!chmod +x ' batchFileBuffer
      execute '!nohup ' batchFileBuffer ' > ~/myVimFiles/vimSwap/nohup.out &'

      " delete the temporary buffer after the program has been started
      execute 'bd! rVim.bat'

      " keeping track of the output
      execute '!tail -f ' outputBuffer

      endif

      endfunction "}}}
      function! OpenROutput() "{{{

      " set the name for the output buffer
      let outputBuffer = expand("%:r:h").'.rout'

      " opening the output buffer
      execute 'e! ' outputBuffer

      " Only one window visible
      execute 'only'

      endfunction "}}}
      function! RToggleCommentify() "{{{
      let lineString = getline(".")
      if lineString != $ " don't comment empty lines
      let commentSymbol = '###'

      let isCommented = stridx(lineString,commentSymbol) " getting the first 3 symbols
      if isCommented == -1
      call Commentify(commentSymbol) " if the line is uncommented, comment
      else
      call UnCommentify(commentSymbol) " if the line is already commented, uncomment
      endif
      endif
      endfunction "}}}
      function! Commentify(commentSymbol) "{{{
      execute 'normal ^i'.a:commentSymbol.' '
      endfunction "}}}
      function! UnCommentify(commentSymbol) "{{{
      set nohlsearch
      execute ':s+'.a:commentSymbol.'\s*++'
      set hlsearch
      endfunction "}}}

      --
      --
      You received this message from the "vim_mac" 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_mac" group.
      To unsubscribe from this group and stop receiving emails from it, send an email to vim_mac+unsubscribe@....
      For more options, visit https://groups.google.com/d/optout.