.vimrc, multiple commands with :map

79 views
Skip to first unread message

Mirai

unread,
Dec 25, 2009, 11:58:23 AM12/25/09
to vim...@googlegroups.com
How can multiple commands be mapped correctly to one key? Here is my .vimrc.

Only the first command, wrap or unwrap, is executed on either line when I hit F7 or F8 unless I execute the commands while editing my .vimrc. Then it raises an error that I don't know how to fix.

Thanks for any help.


View this message in context: .vimrc, multiple commands with :map
Sent from the Vim - General mailing list archive at Nabble.com.

Sven Guckes

unread,
Dec 25, 2009, 4:48:27 PM12/25/09
to vim...@googlegroups.com
* Mirai <mirai...@gmail.com> [2009-12-25 22:00]:

> How can multiple commands be mapped correctly to one key?
> http://pastebin.com/d36ce29a5 Here is my .vimrc.

use the pipe to separate commands:

map <f1> cmd1|cmd2|cmd3

biut i suggest to put all these commands
into a separate file and simply ":source file":

map <f1> :source file<cr>

enjoy!

Sven

--
26th Chaos Communication Congress at Berlin Congress Centre
Sat-Tue 27th-30th December 2009 Alexanderplatz 3, 10178 B.
http://www.ccc.de/congress/2009/ http://www.bcc-berlin.de/
"26C3" Motto: "Here be Dragons!" near tv tower: >=====O---
Lightning Talks: every day 12:45-14:00 in room/saal #3.
http://events.ccc.de/congress/2009/wiki/Lightning_Talks

Marc Weber

unread,
Dec 25, 2009, 5:13:40 PM12/25/09
to vim...@googlegroups.com

> How can multiple commands be mapped correctly to one key?
> http://pastebin.com/d36ce29a5 Here is my .vimrc.

Your issue is that some commands don't allow the bar "|" character
:h command -> search for -bar

The only way to cope with this is using the almighty exec..

exec "cmd" | exec "cmd"

You have to use <bar> instead of | in mappings

However if things get more complex it usually is best to define a
function and call that.

Marc Weber

Reply all
Reply to author
Forward
0 new messages