|
View:
New views
16 Messages
—
Rating Filter:
Alert me
|
|
|
Making visual selectino permanent?Hi, is it possible to make a visual selection permament that way, that only a specific command will un-visual the block? Currently the visual block is unhighlighted after one has -- for example -- entered the wrong :s//-command. Would be nice, if the block remains highlighted after such an error... ;) Best regards, mcc -- Please don't send me any Word- or Powerpoint-Attachments unless it's absolutely neccessary. - Send simply Text. See http://www.gnu.org/philosophy/no-word-attachments.html In a world without fences and walls nobody needs gates and windows. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?On Sun, Nov 8, 2009 at 16:11, <meino.cramer@...> wrote: Benoit Mortgat
Hi, use gv to restore the last visual selection. -- 39, cours Albert Thomas 69003 Lyon, France +33 4 27 78 31 27 / +33 6 17 15 41 58 --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?Benoit Mortgat <mortgat@...> [09-11-08 16:24]: > On Sun, Nov 8, 2009 at 16:11, <meino.cramer@...> wrote: > > > > > Currently the visual block is unhighlighted after one has > > -- for example -- entered the wrong :s//-command. > > > > Hi, use gv to restore the last visual selection. > > -- > Benoit Mortgat > 39, cours Albert Thomas > 69003 Lyon, France > +33 4 27 78 31 27 / +33 6 17 15 41 58 > > > Hi, ...so as a logical consequence: there is no way to make it permanent??? -- Please don't send me any Word- or Powerpoint-Attachments unless it's absolutely neccessary. - Send simply Text. See http://www.gnu.org/philosophy/no-word-attachments.html In a world without fences and walls nobody needs gates and windows. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?> ...so as a logical consequence: there is no way to make it > permanent??? Very likely so. Making a permanent colouring makes it enter a realm more likely covered by the following plugin (albeit not what you were looking for): http://www.vim.org/scripts/script.php?script_id=2208 --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
RE: Making visual selectino permanent?meino.cramer wrote: > is it possible to make a visual selection permament that > way, that only a specific command will un-visual the block? We have a very nice tip for this: http://vim.wikia.com/wiki/Highlight_multiple_words John --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?John Beckett <johnb.beckett@...> [09-11-09 01:48]: > > meino.cramer wrote: > > is it possible to make a visual selection permament that > > way, that only a specific command will un-visual the block? > > We have a very nice tip for this: > http://vim.wikia.com/wiki/Highlight_multiple_words > > John > > > > Thank you for your post! This tipp/script highlights words. Highlighting words does not make them vislually selected. Also would it be an extra command/action as "gv" is one. This is what I initially wanted to prevent. mcc -- Please don't send me any Word- or Powerpoint-Attachments unless it's absolutely neccessary. - Send simply Text. See http://www.gnu.org/philosophy/no-word-attachments.html In a world without fences and walls nobody needs gates and windows. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?On Nov 8, 9:11 am, meino.cra...@... wrote: > Hi, > > is it possible to make a visual selection permament > that way, that only a specific command will un-visual > the block? > > Currently the visual block is unhighlighted after one has > -- for example -- entered the wrong :s//-command. > If you entered the wrong :s command (or any other ex command) you don't actually need to re-highlight the block. Just press : then the up arrow to recall the last command, edit it to taste, and run it again. You'll note the '<,'> remains at the beginning of the line, so it acts on the last selected visual selection regardless of whether you are currently in Visual Mode or not. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?Ben Fritz <fritzophrenic@...> [09-11-09 05:20]: > > > > On Nov 8, 9:11 am, meino.cra...@... wrote: > > Hi, > > > > is it possible to make a visual selection permament > > that way, that only a specific command will un-visual > > the block? > > > > Currently the visual block is unhighlighted after one has > > -- for example -- entered the wrong :s//-command. > > > > If you entered the wrong :s command (or any other ex command) you > don't actually need to re-highlight the block. Just press : then the > up arrow to recall the last command, edit it to taste, and run it > again. You'll note the '<,'> remains at the beginning of the line, so > it acts on the last selected visual selection regardless of whether > you are currently in Visual Mode or not. > > Hi, I know that. I simply want to make the visual selection permament without submitting extra commands / doing extra actions each time by preserving the selection as such. Until now it seems, that this isn't possible with vim. -- Please don't send me any Word- or Powerpoint-Attachments unless it's absolutely neccessary. - Send simply Text. See http://www.gnu.org/philosophy/no-word-attachments.html In a world without fences and walls nobody needs gates and windows. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?On Sun, Nov 8, 2009 at 8:33 PM, <meino.cramer@...> wrote: > > Ben Fritz <fritzophrenic@...> [09-11-09 05:20]: >> >> >> >> On Nov 8, 9:11 am, meino.cra...@... wrote: >> > Hi, >> > >> > is it possible to make a visual selection permament >> > that way, that only a specific command will un-visual >> > the block? >> > >> > Currently the visual block is unhighlighted after one has >> > -- for example -- entered the wrong :s//-command. >> > >> >> If you entered the wrong :s command (or any other ex command) you >> don't actually need to re-highlight the block. Just press : then the >> up arrow to recall the last command, edit it to taste, and run it >> again. You'll note the '<,'> remains at the beginning of the line, so >> it acts on the last selected visual selection regardless of whether >> you are currently in Visual Mode or not. >> > > > Hi, > > I know that. > > I simply want to make the visual selection permament without > submitting extra commands / doing extra actions each time by > preserving the selection as such. > > Until now it seems, that this isn't possible with vim. > If you explain why you want to have your selection visible, then it would help the folks on the list to give the right suggestion. I am not sure if this fits your bill, but my multiselect plugin lets you press <Enter> on the visual selection to add to the list of selections and thus make it appear permanently selected (though it is not in the same sense of a visual selection). The purpose is to be able to run commands on the set of selections, but if all you want is to see the area as selected, it might help. http://www.vim.org/scripts/script.php?script_id=953 -- Hari > > > -- > Please don't send me any Word- or Powerpoint-Attachments > unless it's absolutely neccessary. - Send simply Text. > See http://www.gnu.org/philosophy/no-word-attachments.html > In a world without fences and walls nobody needs gates and windows. > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?On Sun, November 8, 2009 4:11 pm, meino.cramer@... wrote: > is it possible to make a visual selection permament > that way, that only a specific command will un-visual > the block? > > Currently the visual block is unhighlighted after one has > -- for example -- entered the wrong :s//-command. > > Would be nice, if the block remains highlighted after > such an error... ;) ,---- | fu! <SID>MatchVisSel() | let linehl="Visual" " define text-highlight for line | | let b:vstart = getpos("'<")[1:2] | let b:vend = getpos("'>")[1:2] | | if b:vend[1] < 0 | let b:vend[1] = col("'>") | endif | | if b:vstart[0] == 0 | let b:vstart[0] +=1 | endif | | if b:vstart[1] == 0 | let b:vstart[1] +=1 | endif | | | if visualmode() =~# 'V' | " Linewise selection | let regex = '\%>'.(b:vstart[0]-1).'l\_.*\%<' . (b:vend[0]+1) . 'l' | elseif visualmode() =~# 'v' | " Now we need to match something like this: | "\%(\%(\%>15l\)\&\%(\%>7c\)\)\_.*\%(\%(\%<18l\)\&\%(\%<7c\)\) | let regex = '\%(\%(\%>' . (b:vstart[0]-1) . 'l\)\&\%(\%>' . (b:vstart[1]-1) . 'c\)\)\_.*\%(\%(\%<' . (b:vend[0]+1) . 'l\)\&\(\%<' . (b:vend[1]+1) . 'c\)\)' | else | " Now we need to match something like this: | " \%(\%(\%>9l\)\&\%(\%<15l\)\)\@<=\%26c.* | let regex = '\%(\%(\%>' . (b:vstart[0]-1) . 'l\)\&\%(\%<' . (b:vend[0]+1) . 'l\)\)\@<=\%>' . (b:vstart[1]-1) . 'c.*\%<' . (b:vend[1]+1) . 'c' | endif | exe "2match " . linehl . ' /' . regex . '/' | endfu | | fu! <SID>Init(enable) | if a:enable | augroup VisualMatch | au! | au InsertLeave,CursorHold <buffer> :call <SID>MatchVisSel() | augroup END | call <SID>MatchVisSel() | else | augroup VisualMatch | au! | augroup END | augroup! VisualMatch | 2match none | endif | endfu | | com! EnableHilightVisualSelection :call <SID>Init(1) | com! DisableHilightVisualSelection :call <SID>Init(0) `---- Beware of line wrappings in my mail, please. Newer versions of Vim would probably use matchadd(), but my current version (stock 7.1 does not have it, so I used :2match Notice however, that these RE can make Vim quite slow. Don't know if this is caused by the autocommands firing or too slow RE parsing within vim. Also I am not sure, if the RE, always match for all corner cases of visual selection areas. I tested it with some simple cases, but there may exist some edge cases, which possibly could not be matched. (e.g. the line number of '< might be larger thane '> (the same holds for the column number), though I did not observe this effect) regards, Christian -- :wq! --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?meino.cramer@... schrieb: > Hi, > > is it possible to make a visual selection permament > that way, that only a specific command will un-visual > the block? > > Currently the visual block is unhighlighted after one has > -- for example -- entered the wrong :s//-command. > > Would be nice, if the block remains highlighted after > such an error... ;) > > Best regards, > mcc The following code lets the ":" command remember if Visual mode was active. The next c_<Enter> will then restore the Visual area just before (!) executing the Command-line. This is the first version. The code could be greatly simplified by just deciding if "<CR>gv" or "<CR>" is to be executed, but then the Visual area will not be restored after an error (produced by the Ex command). " map ":" and "c_<CR>": map : <Plug>KeepVisAreaSave ounmap : sunmap : cmap <CR> <Plug>KeepVisAreaRestore let s:wasvisual = 0 " Save: no <expr> <Plug>KeepVisAreaSave <sid>RememberVisual(mode()) func! <sid>RememberVisual(mode) let s:wasvisual = a:mode =~ "[vV\<C-V>]" return ":" endfunc " Restore: cno <expr><script> <Plug>KeepVisAreaRestore \ getcmdtype()==":" ? "<SID>ExpandAbbr<SID>DoGv<CR>" : "<CR>" cmap <SID>ExpandAbbr <Space><BS> cno <silent> <SID>DoGv <C-R>=<sid>DoGv()<CR> func! <sid>DoGv() if s:wasvisual normal! gv endif return "" endfunc -- Andy --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?Hari Krishna Dara <hari.vim@...> [09-11-09 18:12]: > > On Sun, Nov 8, 2009 at 8:33 PM, <meino.cramer@...> wrote: > > > > Ben Fritz <fritzophrenic@...> [09-11-09 05:20]: > >> > >> > >> > >> On Nov 8, 9:11 am, meino.cra...@... wrote: > >> > Hi, > >> > > >> > is it possible to make a visual selection permament > >> > that way, that only a specific command will un-visual > >> > the block? > >> > > >> > Currently the visual block is unhighlighted after one has > >> > -- for example -- entered the wrong :s//-command. > >> > > >> > >> If you entered the wrong :s command (or any other ex command) you > >> don't actually need to re-highlight the block. Just press : then the > >> up arrow to recall the last command, edit it to taste, and run it > >> again. You'll note the '<,'> remains at the beginning of the line, so > >> it acts on the last selected visual selection regardless of whether > >> you are currently in Visual Mode or not. > >> > > > > > Hi, > > > > I know that. > > > > I simply want to make the visual selection permament without > > submitting extra commands / doing extra actions each time by > > preserving the selection as such. > > > > Until now it seems, that this isn't possible with vim. > > > > If you explain why you want to have your selection visible, then it > would help the folks on the list to give the right suggestion. I am > not sure if this fits your bill, but my multiselect plugin lets you > press <Enter> on the visual selection to add to the list of selections > and thus make it appear permanently selected (though it is not in the > same sense of a visual selection). The purpose is to be able to run > commands on the set of selections, but if all you want is to see the > area as selected, it might help. > > http://www.vim.org/scripts/script.php?script_id=953 Hi, I often experiment with "reformatting" lists of texts into other lists of texts in a most general sense. Since I am not the regexp guru I want to be, this often fails, must be correct, added some other tweaks and so on. Also I often apply regexp-based commands to a subset of lines of those texts. ,..and I often forget the exact range of the visual selection I done before -- but this is vital to pick the correct regexp for the next magic to perform. I simply git tired to do this in a loop: : <enter partly wrong regexp based command here> <cr> (selection gets deselected here) :gv<cr> : <enter partly wrong regexp based command here> <cr> (selection gets deselected here) :gv<cr> : <enter partly wrong regexp based command here> <cr> (selection gets deselected here) :gv<cr> : <enter partly wrong regexp based command here> <cr> (selection gets deselected here) :gv<cr> : <enter partly wrong regexp based command here> <cr> (selection gets deselected here) :gv<cr> <cr> . . . . and so on. Its simply a kind of lazyness, which lets me ask, how one can make the selection stay on screen as visual as functional. Or with other and less words: I want to make the visual selection being permament because I am lazy (in this case) and lazyness is the driving part of all technical innovation in first place ;) --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?Andy Wokula <anwoku@...> [09-11-09 18:13]: > > meino.cramer@... schrieb: > > Hi, > > > > is it possible to make a visual selection permament > > that way, that only a specific command will un-visual > > the block? > > > > Currently the visual block is unhighlighted after one has > > -- for example -- entered the wrong :s//-command. > > > > Would be nice, if the block remains highlighted after > > such an error... ;) > > > > Best regards, > > mcc > > The following code lets the ":" command remember if Visual mode was > active. The next c_<Enter> will then restore the Visual area just > before (!) executing the Command-line. > > This is the first version. The code could be greatly simplified by just > deciding if "<CR>gv" or "<CR>" is to be executed, but then the Visual > area will not be restored after an error (produced by the Ex command). > > > " map ":" and "c_<CR>": > map : <Plug>KeepVisAreaSave > ounmap : > sunmap : > cmap <CR> <Plug>KeepVisAreaRestore > > let s:wasvisual = 0 > > " Save: > no <expr> <Plug>KeepVisAreaSave <sid>RememberVisual(mode()) > > func! <sid>RememberVisual(mode) > let s:wasvisual = a:mode =~ "[vV\<C-V>]" > return ":" > endfunc > > " Restore: > cno <expr><script> <Plug>KeepVisAreaRestore > \ getcmdtype()==":" ? "<SID>ExpandAbbr<SID>DoGv<CR>" : "<CR>" > > cmap <SID>ExpandAbbr <Space><BS> > cno <silent> <SID>DoGv <C-R>=<sid>DoGv()<CR> > > func! <sid>DoGv() > if s:wasvisual > normal! gv > endif > return "" > endfunc > > -- > Andy > > > Thank you for the scripts! I will test them and see what I can use! Thanks a lot! Kind regards, mcc -- Please don't send me any Word- or Powerpoint-Attachments unless it's absolutely neccessary. - Send simply Text. See http://www.gnu.org/philosophy/no-word-attachments.html In a world without fences and walls nobody needs gates and windows. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?On 2009-11-09, meino.cramer@... wrote: > Hi, > > I often experiment with "reformatting" lists of texts into other > lists of texts in a most general sense. Since I am not the regexp > guru I want to be, this often fails, must be correct, added some > other tweaks and so on. > Also I often apply regexp-based commands to a subset of lines of > those texts. > ,..and I often forget the exact range of the visual selection I done > before -- but this is vital to pick the correct regexp for the next > magic to perform. > I simply git tired to do this in a loop: > : > <enter partly wrong regexp based command here> > <cr> > (selection gets deselected here) > :gv<cr> > : > <enter partly wrong regexp based command here> > <cr> > (selection gets deselected here) > :gv<cr> > . > . > . > . > and so on. > Its simply a kind of lazyness, which lets me ask, how one > can make the selection stay on screen as visual as functional. > > Or with other and less words: > I want to make the visual selection being permament because > I am lazy (in this case) and lazyness is the driving part > of all technical innovation in first place ;) How about this? :cnoremap <CR> <CR>gv To turn off that behavior, :cunmap <CR> HTH, Gary --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?On Nov 9, 12:25 pm, meino.cra...@... wrote: > I simply git tired to do this in a loop: > : > <enter partly wrong regexp based command here> > <cr> > (selection gets deselected here) > :gv<cr> > : > . > . > . > . > and so on. You said you knew that :'<,'> operates on the last visual area without needing to reselect, but your example suggests otherwise. You could just do this: <visually select area of interest> : <enter partially wrong regex> <CR> : <enter partially wrong regex> <CR> : <enter partially wrong regex> ...etc. There is NO NEED to reselect the visual selection if you're operating on the same area that you previously selected. The following commands will ALL operate on the SAME area, until you manually select a new visual selection: :'<,'>s/abc/def/g :'<,'>s/1bc/def/g :'<,'>s/1abc/def/g :'<,'>s/1a2bc/def/g :'<,'>s/12abc/def/g The '<,'> is inserted automatically when you press : in visual mode, and I assume you don't retype the entire regular expression every iteration, but rather use command history to retrieve it and edit it. If so, the '<,'> will already be there. Additionally, you example uses the :gv ex command, a.k.a. :gvim, which starts the gui when Vim is started in a terminal. We have been referring to the gv normal-mode command, which reselects the lats visual area (and is, as I show above, not necessary for your given example). I rarely get complex regular expressions correct on my first try, and use the same overall method that you do to correct them, but without reselecting the visual area already contained in the '< and '> marks. --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
|
|
Re: Making visual selectino permanent?meino.cramer@... schrieb: > Andy Wokula <anwoku@...> [09-11-09 18:13]: >> meino.cramer@... schrieb: >>> Hi, >>> >>> is it possible to make a visual selection permament >>> that way, that only a specific command will un-visual >>> the block? >>> >>> Currently the visual block is unhighlighted after one has >>> -- for example -- entered the wrong :s//-command. >>> >>> Would be nice, if the block remains highlighted after >>> such an error... ;) >>> >>> Best regards, >>> mcc >> The following code lets the ":" command remember if Visual mode was >> active. The next c_<Enter> will then restore the Visual area just >> before (!) executing the Command-line. >> >> This is the first version. The code could be greatly simplified by just >> deciding if "<CR>gv" or "<CR>" is to be executed, but then the Visual >> area will not be restored after an error (produced by the Ex command). >> >> >> " map ":" and "c_<CR>": >> map : <Plug>KeepVisAreaSave >> ounmap : >> sunmap : >> cmap <CR> <Plug>KeepVisAreaRestore >> >> let s:wasvisual = 0 >> >> " Save: >> no <expr> <Plug>KeepVisAreaSave <sid>RememberVisual(mode()) >> >> func! <sid>RememberVisual(mode) >> let s:wasvisual = a:mode =~ "[vV\<C-V>]" >> return ":" >> endfunc >> >> " Restore: >> cno <expr><script> <Plug>KeepVisAreaRestore >> \ getcmdtype()==":" ? "<SID>ExpandAbbr<SID>DoGv<CR>" : "<CR>" >> >> cmap <SID>ExpandAbbr <Space><BS> >> cno <silent> <SID>DoGv <C-R>=<sid>DoGv()<CR> >> >> func! <sid>DoGv() >> if s:wasvisual >> normal! gv >> endif >> return "" >> endfunc > Thank you for the scripts! I will test them and see what I can use! > Thanks a lot! > Kind regards, > mcc Improved (and shorter) version: xmap : <Plug>KeepVisArea vno <script> <Plug>KeepVisArea :<SID>DoGv cno <silent> <SID>DoGv <C-R>=<sid>DoGv()<CR> func! <sid>DoGv() normal! gv if line(".") != line("'>") normal! o endif return "" endfunc Makes sure the cursor is at the end of the selection before executing an Ex-command (otherwise maybe only one line will be left selected afterwards). Now even c_<Esc> will keep the Visual area. Will still not work if a command leaves the cursor at the start of the Visual selection (but that is unlikely). -- Andy --~--~---------~--~----~------------~-------~--~----~ You received this message from the "vim_use" maillist. For more information, visit http://www.vim.org/maillist.php -~----------~----~----~----~------~----~------~--~--- |
| Free embeddable forum powered by Nabble | Forum Help |