Vim: Difference between revisions
From Leo's Notes
This page was last edited on 29 March 2015, at 05:52.
No edit summary |
No edit summary |
||
| Line 1: | Line 1: | ||
== Quick Overview == | |||
TODO: Write guide from onenote. | |||
== Execute Current File using Preset Key == | == Tips == | ||
=== 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 19: | Line 22: | ||
== Toggle Line Numbers == | === Toggle Line Numbers === | ||
To make vi toggle line numbers using a key (in this case, F4), add the following to your <code>.vimrc</code> | To make vi toggle line numbers using a key (in this case, F4), add the following to your <code>.vimrc</code> | ||
| Line 26: | Line 29: | ||
== Multi-line Edit == | === Multi-line Edit === | ||
1,33s/^/ /g | 1,33s/^/ /g | ||
[[Category:TipsnTrics]] | [[Category:TipsnTrics]] | ||
[[Category:Linux]] | [[Category:Linux]] | ||
[[Category:Todo]] | |||
{{Navbox Linux}} | |||
Revision as of 05:52, 29 March 2015
Quick Overview
TODO: Write guide from onenote.
Tips
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
" Will save, then run the interpreter.
au BufEnter * if match( getline(1) , '^\#!') == 0 |
\ execute("let b:interpreter = getline(1)[2:]") |
\endif
fun! CallInterpreter()
if exists("b:interpreter")
exec ("w")
exec ("!".b:interpreter." %")
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>
Multi-line Edit
1,33s/^/ /g