autocmd help - Sending new buffers into tabs
VIM, when opening buffers, seem to hide current one and replace it with the newly opened one. I want it to behave so that it instead opens a new tab and opens the new buffer there. I tried something like: autocmd BufReadPre * call CreateTab() let s:firstcall = 1 function! CreateTab () if (s:firstcall) let s:firstcall = 0 else tabn endif endfunction The firstcall is to ignore the starting file which already has it's own window. This doesn't work so well because somehow BufReadPre doesn't really seem to happen before slamming the buffer into the current window. I have read the helpfile for autocmd a couple of times, but I really can't make out which autocmd is appropriate, there are so many to choose from. -- View this message in context: http://www.nabble.com/autocmd-help---Sending-new-buffers-into-tabs-tf3669182.html#a10252039 Sent from the Vim - General mailing list archive at Nabble.com.
Re: Troubles configuring vim (multi-questions)
Easwy Yang wrote: If you use Vim in windows, see here: http://www.vim.org/tips/tip.php?tip_id=1440 http://www.vim.org/tips/tip.php?tip_id=1314 In Unix, you can use gvim --remote-tab-silent filename But there's no way to do that for just the drag-and-drop operation in gvim? -- View this message in context: http://www.nabble.com/Troubles-configuring-vim-%28multi-questions%29-tf3569025.html#a9979098 Sent from the Vim - General mailing list archive at Nabble.com.
Re: Troubles configuring vim (multi-questions)
I'm not entirely sure what you want here; does having set nosol in your .vimrc help? No it didn't make a difference. When you put the cursor in normal mode over a tab character, which spans several characters, the cursor will be displayed at the end of that area whereas insert mode will put the cursor at the beginning of it. Try mapping it; put the following into your .vimrc: nmap middlemouse :tabccr But that's for the whole file? I was just thinking of when you middleclick over the tab button like in Firefox or Opera. You're getting your modes confused. I think I understand the difference now and my function is pretty neat now. function! HomeKey () let c = col(.) if c == 1 normal ^ else normal ^ if col(.) = c normal 0 endif endif endfunction Can't answer that -- I never use the mouse to drag-and-drop. Even if you set up some autocmds to do this, if you drop the same file onto vim you'll still get extra tabs unless your code sweeps through all the tabs and checks for a name match first. autocmds seems interesting. They're basically callbacks? Would applying some command/function to BufRead that creates a new tab and assigns that tab with the new buffer work? I don't really care if it's dragged and dropped or if it was opened through some command. I was thinking that any opening of a new file should be done by creating a tab for it, but I felt like taking a minimalistic approach and allowing other forms of opening to coexist like using windows or just creating a buffer. By string, do you mean something with double-quotes? I was thinking of an internal string, used in command mode, not having anything to do with the document. But I found a solution in using =~ and substitute(). -- View this message in context: http://www.nabble.com/Troubles-configuring-vim-%28multi-questions%29-tf3569025.html#a9981336 Sent from the Vim - General mailing list archive at Nabble.com.
Troubles configuring vim (multi-questions)
I've been thinking of migrating to using vim (gvim) but I'm running into lots of difficulties on the road I just can't solve, and the documentation is... well, strange at best. * Is it possible to make the cursor stay at it's position even after scrolling it out of view? As it is it follows with your scrolling which is bad because if my mouse suddenly gets the idea of scrolling up you get pretty displaced as well as inserting text where it doesn't belong. Other problems is that a selection, or visual, is also stretched out as the cursor moves. * At the beginning of an indented line, why does normal mode put the cursor at the end of the first tab whereas insert mode is position at the beginning of the line like I think it should? It's annoying to move around in code like that. * Is it possible to enter insert mode for files that aren't modifiable? Obviously any changes can't be saved but the buffer shouldn't be any problems to modify. * Is it possible to close tabs with the middle mouse button? * I wanted the Home-button to act so that it first jumps to the first non-whitespace character of the current line (i.e. skip the indentation) and if Home is pressed when you're already at the first non-whitespace character or before then it should jump to the real beginning of the line, column #1. I made this function: function! HomeKey () let c = col(.) if c == 1 w else g0w if col(.) = c g0 endif endif endfunction This doesn't want to work properly. It extends the command window and dumps some code from the bottom of the .vimrc and then asks for pressing enter and lastly jumps to line #180 in the same file. If c == 1 nothing happens, it doesn't go all wild but that 'w' keypress isn't executed. Also I have noticed that g0 doesn't really take you back to beginning of the line but the beginning of the horizontal scroll. A problem, but it doesn't explain why the code is acting crazy. * In gvim, is it possible to have a drag-and-drop action open the dragged file into a new tab instead of a new buffer? Using the menu is just tedious, and you can't select multiple files either. * I want to check a string if it begins with something but I have no clue why. I was thinking of a regexp but the only way to use matching regexps is for highlights and substition regexps seems to operate on the whole file or a selection and no way to use them on strings. * Can the position of the tab bar be set to the bottom of the window instead of the top? -- View this message in context: http://www.nabble.com/Troubles-configuring-vim-%28multi-questions%29-tf3569025.html#a9970844 Sent from the Vim - General mailing list archive at Nabble.com.
Re: Troubles configuring vim (multi-questions)
inside a script you're in command-mode, and the command w you've meant to should be in normal-mode, the correct way might be :normal w, :normal g0w, etc... Couldn't find anything about command-mode. How is it different from normal mode? Is each line treated as one command? Like g0w is treated as g0w instead of g0 and w? What do you meant by string?, if you think a string should begin with quotation mark, then begin your search regexp with the quotation mark. Not in the document, a string in the vimrc. What I'm trying do to is that if I press F5, which is my run button, and the file is located in my htdocs folder then it will be opened with my browser pointing at the file as seen by the server. elseif expand(%:p:h) == C:\\Program Files\\Apache\\htdocs execute !\C:\\Program Files\\Mozilla Firefox\\firefox.exe\ http://localhost/; . expand(%) It looks sorta like that right now. I want to check if the left side of the == operator begins with the right side. In Perl or Ruby it would be done as elseif expand(%:p:h) =~ /^C:\\Program Files\\Apache\\htdocs/ -- View this message in context: http://www.nabble.com/Troubles-configuring-vim-%28multi-questions%29-tf3569025.html#a9971777 Sent from the Vim - General mailing list archive at Nabble.com.