Wednesday, September 28, 2011

Re: Is there a way to mimic textmate's "wrap each selected line in open/close tag" ?

Dear Amitava Shee,

2011/9/28 Amitava Shee <amitava.shee@gmail.com>
I have starting using the excellent surround.vim plugin. Is there a way to mimic textmate's "wrap each selected line in open/close tag" ?

To surround the current line with say a div-tag, type the following while your cursor is on the line:
Vstdiv
 

Also, I am viws" does not wrap the word with " - instead it deletes the word and puts you between "".  viwS" seems to do the right thing. Is this correct behaviour?

It is. Use ysiw" instead.

See :h surround for details


Kind regards!
Asis

--
You received this message from the "vim_use" 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

Re: Is there a way to mimic textmate's "wrap each selected line in open/close tag" ?

On 09/28/11 07:52, Amitava Shee wrote:
> I have starting using the excellent surround.vim plugin. Is there a way to
> mimic textmate's "wrap each selected line in open/close tag" ?

if you're doing whole lines, I do this infrequently enough that I
just use

:'<,'>s!.*!<tag>&</tag>

which will operate on the highlighted lines or

:g/pattern/s!.*!<tag>&</tag>

to operate on lines matching "pattern". However, if you do it
frequently or need to operate on partial lines, you can investigate

http://www.vim.org/scripts/script.php?script_id=1697

I can't say I've used it, but it's the #1 answer given anytime
anybody asks a question like yours, so it seems to have a lot of
happy users :)

> Also, I am viws" does not wrap the word with " - instead it deletes the word
> and puts you between "". viwS" seems to do the right thing. Is this correct
> behaviour?

I'm not sure what behavior you're expecting here, as

viws"

should visualize the inner word, delete it, leave you in insert
mode where your double-quote appears. OTOH,

viwS"

visualizes the inner word, then deletes the entire line (except
leading whitespace, depending on your indentation settings),
leaves you in insert mode, where your double-quote appears. If
you get behavior different from either of these, you likely have
some mapping interfering that you'd have to track down.

-tim


--
You received this message from the "vim_use" 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

Re: anoying horiz scroll when scrolling down

On 09/28/11 07:59, Razvan Rotaru wrote:
> What happens when I scroll down, is that the cursor is
> following along. The problem occurs when the cursor jumps to a
> short line (which is now out of the screen, because I am
> scrolled to the right) and vim scrolls me back to the left so
> that cursor remains in the screen.
>
> This is incredibly annoying since I have to scroll to the
> right again.

While it has other side-effects, you might try

:set ve=all

which you can read about at

:help 'virtualedit'

It seems to allow me to jump to the end of a long line and then
scroll downward with the cursor landing in virtual-space on the
short lines without triggering the horizontal-scroll back to
where the short lines would normally force me. You can then just
reset it when you don't want it:

:set ve=

-tim


--
You received this message from the "vim_use" 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

anoying horiz scroll when scrolling down

Hi,

I'd like to get rid of an annoying behaviour of vim which happens sometimes when scrolling down.

I have a text file with alternately long and short lines. I want to scroll down the file, while keeping an eye on the "right part" of the long lines (wrap is disabled, so 1 text line is displayed on one screen line, and I have scrolled horizontally the text a little bit, to see the end of the long lines).

What happens when I scroll down, is that the cursor is following along. The problem occurs when the cursor jumps to a short line (which is now out of the screen, because I am scrolled to the right) and vim scrolls me back to the left so that cursor remains in the screen.

This is incredibly annoying since I have to scroll to the right again.

I'd really love some hints about how to get rid of this behaviour. I have searched a little bit around, and found that it is not possible to make the cursor not follow the lines (trying to stay on the screen), mainly because vim is a terminal app.

Cheers,
Razvan

Is there a way to mimic textmate's "wrap each selected line in open/close tag" ?

I have starting using the excellent surround.vim plugin. Is there a way to mimic textmate's "wrap each selected line in open/close tag" ?

Also, I am viws" does not wrap the word with " - instead it deletes the word and puts you between "".  viwS" seems to do the right thing. Is this correct behaviour?

Thanks in advance.

--
You received this message from the "vim_use" 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

Re: Vim as default email (thunderbird) editor

I am using External Editor with Thunderbird 6.02 and everything is working just fine.  I would check to see if you have the latest updates for the plugin.

--
You received this message from the "vim_use" 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

Re: function to get word under cursor

Thanks, John! I probably should check 'vimwiki' first)

2011/9/28 John Beckett <johnb.beckett@gmail.com>
> Is there any standard function to get the word under cursor (
> as */# search commands do ) or I should write it by myself
> using getline('.')?

Use <cword> or <cWORD>. Some examples:
 http://vim.wikia.com/wiki/Highlight_all_search_pattern_matches
 http://vim.wikia.com/wiki/Search_all_files_in_project_quickly
 http://vim.wikia.com/wiki/Search_for_current_word_in_new_window

John

--
You received this message from the "vim_use" 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



--
Best regards
Golubev Mikhail

--
You received this message from the "vim_use" 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