Re: highlighting text
On 23 September 2016, Christian Brabandt wrote: > Hi Markus! > > On Fr, 23 Sep 2016, Markus Knecht wrote: > > > Thanks, matchaddops seems to be exactly the functionality i need, > > sadly I get a failure that the function matchaddpos is unknown, > > probably I'm missing something obvious > > You need to update your vim, or you can use a translate the > matchaddpos() calls to matchadd() calls using the regular expression > atoms /\%l and /\%c and a like (see the help). But since Vim 8.0 was > just recently released, I would go with Vim 8.0 Right, same thing without matchaddpos(): function! HL(group, lstart, cstart, lend, cend) if a:lstart > a:lend return elseif a:lstart == a:lend call matchadd(a:group, printf('\%%%dl\%%>%dc\%%<%dc', \ a:lstart, a:cstart - 1, a:cend + 1)) else call matchadd(a:group, printf('\%%%dl\%%>%dc', a:lstart, a:cstart - 1)) for line in range(a:lstart + 1, a:lend - 1) call matchadd(a:group, printf('\%%%dl', line)) endfor call matchadd(a:group, printf('\%%%dl\%%<%dc', a:lend, a:cend + 1)) endif endfunction /lcd -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: highlighting text
Hi Markus! On Fr, 23 Sep 2016, Markus Knecht wrote: > Thanks, matchaddops seems to be exactly the functionality i need, > sadly I get a failure that the function matchaddpos is unknown, > probably I'm missing something obvious You need to update your vim, or you can use a translate the matchaddpos() calls to matchadd() calls using the regular expression atoms /\%l and /\%c and a like (see the help). But since Vim 8.0 was just recently released, I would go with Vim 8.0 Best, Christian -- Die Schönheit des Alltags entdecken, ist eine Kunst des Lebens. -- A. Bartsch -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: highlighting text
Am Donnerstag, 22. September 2016 08:40:47 UTC+2 schrieb LCD 47: > On 21 September 2016, Markus Knecht wrote: > > Hello, > > > > For a project I have to import some markings into vim and for that I'm > > writing a plugin. These markings are in the form of: > > line start, > > coloumn start, //the start character index > > line end, > > coloumn end, //the end character index > > message > > > > over the signs I have managed to mark the lines and display the > > message when the cursor is on the line. But now I need to highlight > > the characters, like a search does it when hlsearch is enabled, and > > the only thing i found is the matchadd() methode and commands like > > :match, but all of these work with a pattern. But i just need a > > straight forward mark exactly that mechanism which works on a line > > coloumn basis. I would much apriciate it if someone could point me in > > the right direction. > > One way to do it: > > function! HL(group, lstart, cstart, lend, cend) > if a:lstart > a:lend > return > elseif a:lstart == a:lend > call matchaddpos(a:group, [[a:lstart, a:cstart, a:cend - > a:cstart + 1]]) > else > call matchadd(a:group, printf('\%%%dl\%%>%dc', a:lstart, > a:cstart - 1)) > for line in range(a:lstart + 1, a:lend - 1) > call matchaddpos(a:group, [line]) > endfor > call matchadd(a:group, printf('\%%%dl\%%<%dc', a:lend, a:cend > + 1)) > endif > endfunction > > /lcd Thanks, matchaddops seems to be exactly the functionality i need, sadly I get a failure that the function matchaddpos is unknown, probably I'm missing something obvious -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: highlighting text
Am Donnerstag, 22. September 2016 08:40:47 UTC+2 schrieb LCD 47: > On 21 September 2016, Markus Knecht wrote: > > Hello, > > > > For a project I have to import some markings into vim and for that I'm > > writing a plugin. These markings are in the form of: > > line start, > > coloumn start, //the start character index > > line end, > > coloumn end, //the end character index > > message > > > > over the signs I have managed to mark the lines and display the > > message when the cursor is on the line. But now I need to highlight > > the characters, like a search does it when hlsearch is enabled, and > > the only thing i found is the matchadd() methode and commands like > > :match, but all of these work with a pattern. But i just need a > > straight forward mark exactly that mechanism which works on a line > > coloumn basis. I would much apriciate it if someone could point me in > > the right direction. > > One way to do it: > > function! HL(group, lstart, cstart, lend, cend) > if a:lstart > a:lend > return > elseif a:lstart == a:lend > call matchaddpos(a:group, [[a:lstart, a:cstart, a:cend - > a:cstart + 1]]) > else > call matchadd(a:group, printf('\%%%dl\%%>%dc', a:lstart, > a:cstart - 1)) > for line in range(a:lstart + 1, a:lend - 1) > call matchaddpos(a:group, [line]) > endfor > call matchadd(a:group, printf('\%%%dl\%%<%dc', a:lend, a:cend > + 1)) > endif > endfunction > > /lcd Thanks, matchaddpos was exactly the piece of functionality I needed. -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
Re: highlighting text
On 21 September 2016, Markus Knecht wrote: > Hello, > > For a project I have to import some markings into vim and for that I'm > writing a plugin. These markings are in the form of: > line start, > coloumn start, //the start character index > line end, > coloumn end, //the end character index > message > > over the signs I have managed to mark the lines and display the > message when the cursor is on the line. But now I need to highlight > the characters, like a search does it when hlsearch is enabled, and > the only thing i found is the matchadd() methode and commands like > :match, but all of these work with a pattern. But i just need a > straight forward mark exactly that mechanism which works on a line > coloumn basis. I would much apriciate it if someone could point me in > the right direction. One way to do it: function! HL(group, lstart, cstart, lend, cend) if a:lstart > a:lend return elseif a:lstart == a:lend call matchaddpos(a:group, [[a:lstart, a:cstart, a:cend - a:cstart + 1]]) else call matchadd(a:group, printf('\%%%dl\%%>%dc', a:lstart, a:cstart - 1)) for line in range(a:lstart + 1, a:lend - 1) call matchaddpos(a:group, [line]) endfor call matchadd(a:group, printf('\%%%dl\%%<%dc', a:lend, a:cend + 1)) endif endfunction /lcd -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.
highlighting text
Hello, For a project I have to import some markings into vim and for that I'm writing a plugin. These markings are in the form of: line start, coloumn start, //the start character index line end, coloumn end, //the end character index message over the signs I have managed to mark the lines and display the message when the cursor is on the line. But now I need to highlight the characters, like a search does it when hlsearch is enabled, and the only thing i found is the matchadd() methode and commands like :match, but all of these work with a pattern. But i just need a straight forward mark exactly that mechanism which works on a line coloumn basis. I would much apriciate it if someone could point me in the right direction. Kind Regards Markus Knecht -- -- You received this message from the "vim_dev" maillist. Do not top-post! Type your reply below the text you are replying to. For more information, visit http://www.vim.org/maillist.php --- You received this message because you are subscribed to the Google Groups "vim_dev" group. To unsubscribe from this group and stop receiving emails from it, send an email to vim_dev+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.