Giter Site home page Giter Site logo

vim-run's Introduction

vim-run

screenshot screenshot

Run any file and show output inside vim.

Usage

With config

let g:run_mapping = 'go' " default mapping

let g:run_cmd = {
      \'c':           'gcc -Wall -Wextra -std=c99 -pedantic',
      \'c_plus':      './a.out',
      \'java':        'javac -Xdiags:verbose -Xlint:unchecked',
      \'java_plus':   'java %:r',
      \'python':      'python',
      \'javascript':  'node',
      \'tsx':         'tsc --outFile %t %',
      \'tsx_plus':    'node %t',
      \'vim':         'source',  
      \}

Open a tmp.c or tmp.py file and Press go in NORMAL mode. Vim will run the file and split a window to display the output.

Installation

How to install
  • VundleVim

      Plugin 'leafOfTree/vim-run'
    
  • vim-pathogen

      cd ~/.vim/bundle && \
      git clone https://github.com/leafOfTree/vim-run --depth 1
    
  • vim-plug

      Plug 'leafOfTree/vim-run'
      :PlugInstall
    
  • Or manually, clone this plugin to path/to/this_plugin, and add it to rtp in vimrc

      set rtp+=path/to/this_plugin
    

Please stay up to date. Feel free to open an issue or a pull request.

Configuration

g:run_cmd

  • { key: <filetype>, value: <cmd> }

  • { key: <filetype>_plus, value: <cmd> }

  • description:

    Set <cmd> for <filetype>. The filename is appended to the <cmd>.

    • If there are special chars in <cmd>, they will be replaced with a proper value. Meanwhile the filename won't be appended to the <cmd>.

      Special chars Value
      % Filename
      %:r Filename without extension
      %t Temp filename given by vim
    • Optional: set <cmd> for <filetype>_plus which runs after the previous one. Useful when the previous only compiles the file.

  • type: Dictionary

  • default: Undefined

  • example:

    let markdown_to_html = 'pandoc 
          \ --metadata title="%" 
          \ -c http://cdn.bootcss.com/bootstrap/3.3.5/css/bootstrap.min.css 
          \ -s % -o %:r.html'
    
    let g:run_cmd = {
          \'c':             'gcc -Wall -Wextra -std=c99 -pedantic',
          \'c_plus':        './a.out',
          \'cpp':           'g++ -Wall -Wextra -pedantic',
          \'javascript':    'node',
          \'python':        'python',
          \'markdown':      markdown_to_html,
          \'markdown_plus': 'open %:r.html',
          \'vim':           'source',  
          \}

Note: you need to use 'source' for vim files.

g:run_mapping

  • description: key mapping to run the current file in Normal mode.

  • default: 'go'

  • example:

    let g:run_mapping = '<F5>'

Or you can map key as usual

nnoremap <c-cr> <Cmd>call run#Run()<cr>
inoremap <c-cr> <Cmd>call run#Run()<cr>

g:run_output_focus

Focus the output window. Default: 0. (0 or 1).

g:run_output_scroll_bottom

Let the output window scroll to bottom. Default: 0. (0 or 1).

g:run_output_vertically

Split output window vertically. Default: 0. (0 or 1).

g:run_debug

Show debug messages. Default: 0. (0 or 1).

Custom output syntax highlighting

You can add syntax/run-<filetype>.vim to custom <filetype> output's syntax highlighting. Examples are syntax/run-go.vim, syntax/run-c.vim, ...

vim-run's People

Contributors

leafoftree avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

vim-run's Issues

Installation

Hello, this is a great thing that I want in for my vim.
can you explain to me how I can install this?
I have rtp = ~/.vim_runtime as path

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.