Vim: Difference between revisions
From Leo's Notes
This page was last edited on 22 April 2013, at 05:28.
Created page with " == Map F5 to execute current file == To make vi execute a script that is being edited using a function key (in this case, F5), add the following to your <code>.vimrc</code> ..." |
|||
| Line 1: | Line 1: | ||
== | == Execute Current File using Preset Key == | ||
To make vi execute a script that is being edited using a function key (in this case, F5), add the following to your <code>.vimrc</code> | To make vi execute a script that is being edited using a function key (in this case, F5), add the following to your <code>.vimrc</code> | ||
| Line 18: | Line 18: | ||
== Toggle Line Numbers == | |||
To make vi toggle line numbers using a key (in this case, F4), add the following to your <code>.vimrc</code> | |||
" Map F4 to toggle line numbers | |||
map <F4> :set nonumber!<CR> | |||
[[Category:TipsnTrics]] | [[Category:TipsnTrics]] | ||
[[Category:Linux]] | |||
Revision as of 05:28, 22 April 2013
Execute Current File using Preset Key
To make vi execute a script that is being edited using a function key (in this case, F5), add the following to your .vimrc
" Mapping F5 to run hashbang scripts
au BufEnter * if match( getline(1) , '^\#!') == 0 |
\ execute("let b:interpreter = getline(1)[2:]") |
\endif
fun! CallInterpreter()
if exists("b:interpreter")
exec ("w") # Save
exec ("!".b:interpreter." %") # Then run
endif
endfun
map <F5> :call CallInterpreter()<CR>
Toggle Line Numbers
To make vi toggle line numbers using a key (in this case, F4), add the following to your .vimrc
" Map F4 to toggle line numbers map <F4> :set nonumber!<CR>