2013-10-26 2 views

답변

3

확인 그래서이 작품 몇 가지 실험 후 : 당신이 환경 변수를 제대로 설정했다고 가정 !go run %

+0

'au FileType go map r :! go run % ' – hendry

2

; (이 C:\Users\UserName에 있어야 Windows에서, 리눅스, 나도 몰라)이 _gvimrc 파일을 사용할 수 있습니다 :

set guifont=Lucida_Console:h11 
colorscheme dejavu 
set tabstop=4 

filetype plugin on 
filetype plugin indent on 
syntax on 

" causes vim opens maximized in windows (@least) 
au GUIEnter * simalt ~x 

set autochdir 
set number 
set nobackup 
" set nowritebackup 

" this made my vim life (as a begginer at least) much happier! 
" thanks to @ http://vim.wikia.com/wiki/Display_output_of_shell_commands_in_new_window bottom of the page 
function! s:ExecuteInShell(command, bang) 
    let _ = a:bang != '' ? s:_ : a:command == '' ? '' : join(map(split(a:command), 'expand(v:val)')) 

    if (_ != '') 
     let s:_ = _ 
     let bufnr = bufnr('%') 
     let winnr = bufwinnr('^' . _ . '$') 
     silent! execute winnr < 0 ? 'belowright new ' . fnameescape(_) : winnr . 'wincmd w' 
     setlocal buftype=nowrite bufhidden=wipe nobuflisted noswapfile wrap number 
     silent! :%d 
     let message = 'Execute ' . _ . '...' 
     call append(0, message) 
     echo message 
     silent! 2d | resize 1 | redraw 
     silent! execute 'silent! %!'. _ 
     silent! execute 'resize ' . line('$') 
     silent! execute 'syntax on' 
     silent! execute 'autocmd BufUnload <buffer> execute bufwinnr(' . bufnr . ') . ''wincmd w''' 
     silent! execute 'autocmd BufEnter <buffer> execute ''resize '' . line(''$'')' 
     silent! execute 'nnoremap <silent> <buffer> <CR> :call <SID>ExecuteInShell(''' . _ . ''', '''')<CR>' 
     silent! execute 'nnoremap <silent> <buffer> <LocalLeader>r :call <SID>ExecuteInShell(''' . _ . ''', '''')<CR>' 
     silent! execute 'nnoremap <silent> <buffer> <LocalLeader>g :execute bufwinnr(' . bufnr . ') . ''wincmd w''<CR>' 
     nnoremap <silent> <buffer> <C-W>_ :execute 'resize ' . line('$')<CR> 
     silent! syntax on 
    endif 
endfunction 

command! -complete=shellcmd -nargs=* -bang Shell call s:ExecuteInShell(<q-args>, '<bang>') 
cabbrev shell Shell 

" my additional tools 
command! -complete=shellcmd -nargs=* -bang Gor call s:ExecuteInShell('go run %', '<bang>') 
command! -complete=shellcmd -nargs=* -bang Gon call s:ExecuteInShell('go install', '<bang>') 
command! -complete=shellcmd -nargs=* -bang Gob call s:ExecuteInShell('go build', '<bang>') 
command! -complete=shellcmd -nargs=* -bang Got call s:ExecuteInShell('go test -v', '<bang>') 

:map <F5> :Gor<CR> 
:map <F6> :Gob<CR> 
:map <F7> :Gon<CR> 
:map <F9> :Got<CR> 
:map <F10> :Fmt<CR>:w<CR> 
:map <F12> :q<CR> 

cabbrev fmt Fmt 

:set encoding=utf-8 
:set fileencodings=utf-8 

을 이제 당신이 (go run file.go를) 이동 실행 F5을 누르면 다른에서 출력을 보여줍니다 문서 (다른 문서를 닫으려면 :q 수 있습니다). 다른 명령은 F6 빌드, F7 설치, F9 시험 및 (내 사랑하는 사람) F10fmt + :w입니다.

은 BTW dejavu은 (코드 고릴라/MUX에서이다) 내가 가장 좋아하는 색상 체계입니다 :

enter image description here

관련 문제