LinuxQuestions.org
LinuxAnswers - the LQ Linux tutorial section.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices

Reply
 
LinkBack Search this Thread
Old 11-03-2009, 06:54 PM   #1
voyciz
Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 425

Rep: Reputation: 40
Vim function and key mapping


Hello all, having a little trouble with defining a vim function and mapping a key sequence to it, any help would be greatly appreciated. The documentation is a little confusing to me.

Quote:
function Slackbuild()
:%s/ARCH:-i486/ARCH:-x86_64<CR>
:%s/OUTPUT:-\/tmp/OUTPUT:-\/usr\/local\/my_builds<CR>
endfunction
map _sb call Slackbuild()
So I'm trying to map the "_sb" key sequence to Slackbuild() and having some trouble. I'm guessing I'm not listing the correct commands within the function. Originally I was gonna use:

Quote:
map _sb :%s/ARCH:-i486/ARCH:-x86_64<CR>:%s/OUTPUT:-\/tmp/OUTPUT:-\/usr\/local\/my_builds<CR>
...but the problem I ran into was that if the first substitution command was not successfull, then the second was not carried out.
 
Old 11-03-2009, 11:11 PM   #2
voyciz
Member
 
Registered: Mar 2004
Distribution: Slackware
Posts: 425

Original Poster
Rep: Reputation: 40
Quote:
function Slackbuild()
let [lnum, col]=searchpos("ARCH:-i486",'n')
let repl = substitute(getline(lnum),"i486","x86_64","g")
call setline(lnum,repl)
let [lnum,col]=searchpos("OUTPUT:-\/tmp",'n')
let repl = substitute(getline(lnum),"\/tmp","\/usr\/local\/my_builds","g")
call setline(lnum,repl)
endfunction
map _sb :exec Slackbuild()<CR>
So after experimenting for a while, I have something that works. I have a feeling this isn't the best way to do it though. If anyone has any input, let me know please.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using mapping in VIM to add HTML? gaikokujinkyofusho Linux - Newbie 3 05-04-2009 11:57 PM
Mapping AltGr key to act as WIN key krisrao Linux - Newbie 3 02-11-2009 08:14 PM
Key Mapping SPK Linux - General 1 08-15-2006 11:27 AM
mapping a key to compile a program in vim dvm Linux - Software 1 01-26-2005 07:56 AM
Mapping Esc to windows key in Vim frankie_DJ Linux - Newbie 2 10-14-2004 02:56 PM


All times are GMT -5. The time now is 04:02 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration