Skip to content

SamTebbs33/vim-exec

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 

Repository files navigation

vim-exec

A vim plugin that executes the current file.

Contents

Install pathogen, and then clone this repo into your .vim/bundle directory.

cd ~/.vim/bundle && git clone https://github.com/SamTebbs33/vim-exec

The default key mapping is to F12, which can be changed by reassigning g:vim_exec_key in your .vimrc and then calling VimExecMap().

" Map to <leader>e
let g:vim_exec_key = "<leader>e"
call VimExecMap()

Some common commands are provided by default (run :call VimExecCmds() to see a list of those), but more can be added easily. The variable that stores the commands is called g:vim_exec_cmds and is a dictionary, where the key is the filetype and the value is the command to execute. To create a new command or override an existing one:

let g:vim_exec_cmds["filetype"] = "cmd"

Where "filetype" is the filetype you want the command to apply to and "cmd" is the command itself. Use % to represent the path to the current file. Note that : is added to the beginning and <CR> is not needed at the end. Open a file of the filetype and press the key that is bound to VimExec to test the new command.

If you'd like to add a command that will be supplied by default, fork the repo, edit the plugin/vim-exec.vim file and add the filetype and command to the end of the g:vim_exec_cmds dictionary.

let g:vim_exec_cmds = {..., "new-filetype" : "new-comand"}

Then open a pull request. I will merge the pull request if the change is relevant and doesn't do anything malicious to the user's system (i.e, no rm -rf /*)

By default, VimExec will not clear the terminal screen (not the vim buffer window) before executing a command. To enable this:

let g:vim_exec_clear = 1

To change the command used to clear the screen (It is clear by default):

let g:vim_exec_clearcmd = "cls"

vim-exec can output to a tmux pane rather than the default terminal if vimux is installed. To enable this:

let g:vim_exec_vimux = 1

You must be runnign an instance of tmux in order for this to work.

Below is a list of the filetypes that are supported by default and their requirements (if there are any).

  • Python
  • OCaml
  • VimScript
  • JavaScript: Node.js
  • HTML
  • Bash script
  • Haskell: Ghci

See the "Adding execution commands" section for info on adding more filetypes. More will be added to the default set when they are thought of.

About

Execute current file open in vim

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published