sending code from vim to stata

半城伤御伤魂 提交于 2019-12-04 03:12:33

If you're going to switch to linux (for good) you should 1. call stata and switch your license to a linux license (which they'll do for free) and install it natively, then starting stata from vim just requires a bash script (i'm no expert on vim) 2. or, you could buy stata 11, which has one license for all supported platforms 3. you could install stata with wine (play on linux made it easier for me) but I couldn't get wine to give stata more than half a gig of ram, so i installed native stata10

I use gedit for python, stata, R, latex, et cetera, it handles anything, and gtksourceview is pretty easy to add syntax highlighting and styles et cetera..

Python is great for data analysis, please see

http://www.scipy.org/ http://openopt.org/Welcome http://www.macworld.com/appguide/app.html?id=63924&expand=false

For scraping websites theres

http://scrapy.org/ http://wwwsearch.sourceforge.net/mechanize/

and for parsing data out of text generally we have, http://pyparsing.wikispaces.com/

I have a bunch of files you might find useful (gtksoureview language definitions for stata and others, pdf copies of some books (some copyleft)) but i don't know how to attach files on this website

in linux you can use a plugin for vim called slime.vim which will allow you to pipe code from vim to a running R process without leaving vim. I use this on the mac for mysql, php, python and ocaml and it works great. The only caveat is that it uses screen to do its magic which is not a bad thing in itself.

If I understand your question correctly I believe this will help you enormously. Good luck and hope that helps you.

asoundmove

[Edit]: Oops, I noticed that your main question relates to the AutoIt script, sorry I don't know how to translate this to Linux. I don't think there is any easy way. You might want to look into into xautomation or other similar tools, but that's a totally different ball game.

In your .vimrc replace:

!start "C:\Programme\Stata10\integvim\rundo3\rundo.exe" "%:p"

With the command that does the same thing in linux. It should look similar to this:

!/usr/share/... "%:p"

As I don't have a clue about Stata, you'll have to find out the exact command from someone else.

Also I'm not sure about the "%:p": please look that up in the vim help and compare the differences between Windows and Linux.

I rarely use stata anymore, but at some point worked out a quick solution in bash. this script, executed with a few lines in my .vimrc, works fine. you might have to adjust the delays depending on your system.

#!/bin/bash

# needs wmctrl, xte and xsel
# to get them run
# sudo apt-get install wmctrl xautomation xsel
# in debian/ubuntu linux

#copy to clipboard "do filename"
echo 'do ' '"'$1'"' | xsel -b

# get current window id
winid = $(xprop -root | awk '/_NET_ACTIVE_WINDOW\(WINDOW\)/{print $NF}')

# check for stata window, if found activate else execute
# use correct version here
if [ "$(pgrep stata)" ] 
then
    wmctrl -a 'Stata/MP 11.2'
else
    xstata &
    sleep .1 
fi

# delay depends on window manager etc
# .1 ok with xmonad in 10.04
sleep .1 

# switch to command line, ctrl-4 in stata 10, ctrl-1 in 11/12
# and select existing text via ctrl-a
xte 'keydown Control_L' 'key 1' 'key A' 'usleep 100' \
    'key V' 'keyup Control_L' 
sleep .1
xte 'key Return'
sleep .3


# go back to editor window
wmctrl -i -a $winid 

adjust this and put it in your vimrc.

"" STATA DO-FILE SCRIPTS
fun! RunIt()
  w
  "adjust this path to the bash script
  !sh "/home/username/.rundo.sh" "%:p"
endfun
au FileType stata noremap <F8> :<C-U>call RunIt()<CR><CR>
fun! RunDoLines()
  let selectedLines = getbufline('%', line("'<"), line("'>"))
 if col("'>") < strlen(getline(line("'>")))
  let selectedLines[-1] = strpart(selectedLines[-1], 0, col("'>"))
  endif
 if col("'<") != 1
  let selectedLines[0] = strpart(selectedLines[0], col("'<")-1)
  endif
 let temp = tempname() . ".do"
  call writefile(selectedLines, temp)
          "adjust this path to the bash script
          exec "!sh /home/username/.rundo.sh " . temp
    "au VimLeave * exe "!del -y" temp
    au VimLeave * silent exe '!del /Q "'.$TEMP.'\*.tmp.do"'
endfun
au FileType stata noremap <F9> :<C-U>call RunDoLines()<CR><CR> 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!