2015年12月7日 星期一

VIM script


Vim - map shell command - Stack Overflow
http://stackoverflow.com/questions/9364040/vim-map-shell-command

Note some things:
  1. Don’t use map (without n and nore) unless you have a specific reason. I believe you don’t need this mapping for visual and operator-pending modes (leading n restricts mapping to normal mode only) and you also should not want this mapping to be remappable.
  2. Use to discard count you can occasionally type unless you do know you need it (third version uses two hacks that turn mapping to no-op with a side-effect and does not need ).
  3. Never forget to escape shell arguments.
  4. Version with silent ! (do not forget space after silent, this is why @David Pope’s answer does not work) has at the end. This is because using ! will always provide access to your terminal and thus redraw is needed after command has run.
  5. Versions with system() won’t work if you add an argument containing newline, it is a documented bug. If you don’t want to do so (expand('') won’t ever add newline) it is absolutely safe.
  6. t is a very useful motion. It is better to learn to use it then remap it to something. I suggest ,t as a lhs.
Mapping keys in Vim - Tutorial (Part 1) - Vim Tips Wiki - Wikia
http://vim.wikia.com/wiki/Mapping_keys_in_Vim_-_Tutorial_%28Part_1%29

Mapping key sequences
http://osr507doc.sco.com/en/OSUserG/_mapping_key_sequences.html

Vim documentation: help
http://vimdoc.sourceforge.net/htmldoc/help.html
Vim documentation: usr_41
http://vimdoc.sourceforge.net/htmldoc/usr_41.html
Vim documentation: map
http://vimdoc.sourceforge.net/htmldoc/map.html

Learn Vimscript the Hard Way
http://learnvimscriptthehardway.stevelosh.com/

沒有留言: