diff --git a/install_awesome_parameterized.sh b/install_awesome_parameterized.sh index f9b08ec2..ee4be411 100755 --- a/install_awesome_parameterized.sh +++ b/install_awesome_parameterized.sh @@ -10,7 +10,7 @@ source $1/vimrcs/basic.vim source $1/vimrcs/filetypes.vim source $1/vimrcs/plugins_config.vim source $1/vimrcs/extended.vim -source $1/vimrcs/run_code.vim + try source $1/my_configs.vim catch diff --git a/install_awesome_vimrc.sh b/install_awesome_vimrc.sh index f83eb9a3..948f97e9 100755 --- a/install_awesome_vimrc.sh +++ b/install_awesome_vimrc.sh @@ -9,7 +9,6 @@ source ~/.vim_runtime/vimrcs/basic.vim source ~/.vim_runtime/vimrcs/filetypes.vim source ~/.vim_runtime/vimrcs/plugins_config.vim source ~/.vim_runtime/vimrcs/extended.vim -source ~/.vim_runtime/vimrcs/run_code.vim try source ~/.vim_runtime/my_configs.vim catch diff --git a/vimrcs/extended.vim b/vimrcs/extended.vim index 459b085a..06af0f6e 100644 --- a/vimrcs/extended.vim +++ b/vimrcs/extended.vim @@ -172,3 +172,59 @@ endfunc func! CurrentFileDir(cmd) return a:cmd . " " . expand("%:p:h") . "/" endfunc + +"================================================================================= +" +" Following file contains the commands on how to run the currently open code. +" The default mapping is set to F5 like most code editors. +" Change it as you feel comfortable with, keeping in mind that it does not +" clash with any other keymapping. +" +" NOTE: Compilers for different systems may differ. For example, in the case +" of C and C++, we have assumed it to be gcc and g++ respectively, but it may +" not be the same. It is suggested to check first if the compilers are installed +" before running the code, or maybe even switch to a different compiler. +" +" NOTE: Adding support for more programming languages +" +" Just add another elseif block before the 'endif' statement in the same +" way it is done in each case. Take care to add tabbed spaces after each +" elseif block (similar to python). For example: +" +" elseif &filetype == '<your_file_extension>' +" exec '!<your_compiler> %' +" +" NOTE: The '%' sign indicates the name of the currently open file with extension. +" The time command displays the time taken for execution. Remove the +" time command if you dont want the system to display the time +" +"================================================================================= + +map <F5> :call CompileRun()<CR> +imap <F5> <Esc>:call CompileRun()<CR> +vmap <F5> <Esc>:call CompileRun()<CR> + +func! CompileRun() +exec "w" +if &filetype == 'c' + exec "!gcc % -o %<" + exec "!time ./%<" +elseif &filetype == 'cpp' + exec "!g++ % -o %<" + exec "!time ./%<" +elseif &filetype == 'java' + exec "!javac %" + exec "!time java %" +elseif &filetype == 'sh' + exec "!time bash %" +elseif &filetype == 'python' + exec "!time python %" +elseif &filetype == 'html' + exec "!google-chrome % &" +elseif &filetype == 'go' + exec "!go build %<" + exec "!time go run %" +elseif &filetype == 'matlab' + exec "!time octave %" +endif +endfunc diff --git a/vimrcs/run_code.vim b/vimrcs/run_code.vim deleted file mode 100644 index 1dd2ba30..00000000 --- a/vimrcs/run_code.vim +++ /dev/null @@ -1,55 +0,0 @@ -"================================================================================= -" -" Following file contains the commands on how to run the currently open code. -" The default mapping is set to F5 like most code editors. -" Change it as you feel comfortable with, keeping in mind that it does not -" clash with any other keymapping. -" -" NOTE: Compilers for different systems may differ. For example, in the case -" of C and C++, we have assumed it to be gcc and g++ respectively, but it may -" not be the same. It is suggested to check first if the compilers are installed -" before running the code, or maybe even switch to a different compiler. -" -" NOTE: Adding support for more programming languages -" -" Just add another elseif block before the 'endif' statement in the same -" way it is done in each case. Take care to add tabbed spaces after each -" elseif block (similar to python). For example: -" -" elseif &filetype == '<your_file_extension>' -" exec '!<your_compiler> %' -" -" NOTE: The '%' sign indicates the name of the currently open file with extension. -" The time command displays the time taken for execution. Remove the -" time command if you dont want the system to display the time -" -"================================================================================= - -map <F5> :call CompileRun()<CR> -imap <F5> <Esc>:call CompileRun()<CR> -vmap <F5> <Esc>:call CompileRun()<CR> - -func! CompileRun() -exec "w" -if &filetype == 'c' - exec "!gcc % -o %<" - exec "!time ./%<" -elseif &filetype == 'cpp' - exec "!g++ % -o %<" - exec "!time ./%<" -elseif &filetype == 'java' - exec "!javac %" - exec "!time java %" -elseif &filetype == 'sh' - exec "!time bash %" -elseif &filetype == 'python' - exec "!time python %" -elseif &filetype == 'html' - exec "!google-chrome % &" -elseif &filetype == 'go' - exec "!go build %<" - exec "!time go run %" -elseif &filetype == 'matlab' - exec "!time octave %" -endif -endfunc