import vim, socket, sys, string, re, os cw = vim.current.window row,col = cw.cursor currl = vim.current.line #if currl[col-1] == '{' and currl[col-5:col-1] == 'cite': if 1: # connect to the socket, send a /currcite/ message and # get back the citations and insert them sockpath = os.path.join(os.environ['HOME'],'.pybibsocket') sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM) sock.connect(sockpath) sent = sock.send('/currcite/') msglen = int(sock.recv(5)) msg = sock.recv(msglen) sock.close() # so we have the msg. Lets make it pretty if string.find(msg,'/') == -1: # single citation pass else: msg = re.sub('/',',',msg) msg = ' \cite{'+msg+'} ' currl = currl[:col] + msg+currl[col+len(msg):len(currl)-1] vim.current.line = currl x = """ sdfsdsfsf sfsfsdfsfsfsfsfsfsfsfs \cite{jchemom:2002:16:490,jchemom:2001:15:353,jcamd:1996:10:521} """