Stata The Stata listserver
[Date Prev][Date Next][Thread Prev][Thread Next][Date index][Thread index]

RE: st: Text editors FAQ updated

Subject   RE: st: Text editors FAQ updated
Date   Mon, 21 Jun 2004 10:53:30 -0400

Dimitriy V. Masterov
> This text editor FAQ is incredibly useful. I've been using gvim for
> a few months now, and it makes editing do files much more pleasant
> and a lot quicker.

> I was wondering if some user would be kind enough to share his
> _gvimrc file with the list. This is a list of commands in this are
> executed when the GUI is started. I've been adding features (see
> my own file below), but I feel there are many I don't even imagine
> that would be useful, especially with Stata. In particular, is there
> a way to run the do file as some sort of ex command?

I have been using Vim since January and it works great for me.  I
particularly enjoy being able to customize keyboard mappings, virtually no
limits on the number of mappings.  My _vimrc file follows.  The Stata
relevant lines are:

  autocmd FileType stata set tabstop=4 shiftwidth=4 expandtab smartindent
  map <F8> :!start "c:/program files/stata8/wstata.exe" do "%:p"

Note the F8 mapping allows you to run do files.

Patrick Joly

-----_vimrc-----<begin here>----

set nocompatible
source $VIMRUNTIME/vimrc_example.vim
source $VIMRUNTIME/mswin.vim
behave mswin
colorscheme darkslategray

" Win32 only - maximize Window (i.e. simulates Alt-space, then x)
" simalt ~x " doesn't seem to work, in does from command-line though
" maximize using :winpos and :set ... instead
winpos 0 0
set lines=39
set columns=125

set shortmess+=I
set sessionoptions+=unix,slash
set sessionoptions+=winpos,resize
set sessionoptions-=options
set nobackup

if has("gui_win32")
    set diffexpr=MyDiff()
    function MyDiff()
      let opt = ''
      if &diffopt =~ 'icase' | let opt = opt . '-i ' | endif
      if &diffopt =~ 'iwhite' | let opt = opt . '-b ' | endif
      silent execute '!"C:\Program Files\vim\vim62\diff" -a ' . opt . '"' .
v:fname_in . '" "' . v:fname_new . '" > "' . v:fname_out . '"'

if has("gui_running")
    if has("gui_gtk2")
        set guifont=Courier\ New\ 10
    elseif has("x11")
        set guifont=-*-courier-medium-r-normal-*-*-180-*-*-m-*-*
        set guifont=Courier_New:h10:cDEFAULT

filetype on
autocmd FileType perl  set tabstop=4 shiftwidth=4 expandtab
autocmd FileType stata set tabstop=4 shiftwidth=4 expandtab smartindent

" enable POD syntax high-lighting
let perl_include_POD = 1
" changes how Perl displays package names in references (such as
let perl_want_scope_in_variables = 1
" complex variable declarations such as @{${var}}
let perl_extended_vars = 1
" treat strings as a statement
let perl_string_as_statement = 1

map <F8> :!start "c:/program files/stata8/wstata.exe" do "%:p"
map <F5> :!perl "%"
map <F6> :!start perl -d "%"
map <F7> :!podchecker "%"
map <F2> :buffers<CR>:sb 
map <F3> :buffers<CR>:e #
map <C-Tab> <C-W>w

map ,gm1 :%s/\([0-9-]\+\) \+\([0-9-]\+\)/\1,\2/gc
map ,gm2 :%s/)\s*$/)./gc

" t stands for tourism, v for vnumbers
map ,tv1 :3,$s/^[^V]\+.*\n//gc
map ,tv2 :%s/^\(V\d\+\) .*$/\1/gc
map ,tv3 :3,$s!\n! !gc

" v stands for vnumbers, (CANSIM II 'view vector directory')
map ,v1 :%s/\s\+$/
map ,v2 :%s/\s\+\d\+-\d\+-\d\+.*$//g
map ,v3 :%s/\n^\s\+/ /g
map ,v4 :g/Current prices/d   
map ,v5 :%s/\d\.\d.[^\s]\+\s\+//g
map ,v6 :%s/\(v\d\+\).*$\n/\1 /gc

" perl one-liners
map ,p1 :!perl -pi.bak -e 's/\r//g' "%:p"

-----_vimrc-----<ends here>----

*   For searches and help try:

© Copyright 1996–2024 StataCorp LLC   |   Terms of use   |   Privacy   |   Contact us   |   What's new   |   Site index