Wednesday, August 22, 2012

Re: gedit to gvim/vim teething issues

On Wed, 22 Aug 2012, naphelge wrote:

> [...]
>
> nnoremap ,cd :cd %:p:h<CR>:pwd<CR>
> nmap <silent> <leader>te :!/usr/bin/xfce4-terminal<CR>
> With these two mapped keys I can switch the current VIM window to the
> $PWD of the file I am currently editing and then execute the command
> to run a terminal in the directory. Almost perfect, but while in
> terminal the gVim file is unavailable. Is there a way to run the
> terminal concurrent with the opened file so I can edit the file, run
> commands in the terminal to edit the file and back and forth like
> that?

Change the second mapping to:

nmap <silent> <leader>te :!/usr/bin/xfce4-terminal &<CR>

The ampersand tells your shell to run the command in the background.


> also, it seems like gVim gets hung up when I run a sed command let's
> say on the file. I get a message box informing me the file has changed
> with the options to hit ok or load file. [...]
>
> [...] I use sed so much to edit html files I try to escape as little
> as I can get away with and so sed -ri functionality is what I am
> looking for.

Instead of using :!sed -ri {sed program here} %
Try: :%!sed -r {sed program here}

In the first case, Vim launches a shell and runs `sed` with the current
file as an argument. Vim has no way to know that you've intentionally
run it with the '-i' in-place replacement, so it runs its usual "The
file changed from under me" logic. In the latter case, Vim is filtering
the selected lines through the `sed` program ('%' is equivalent to a
range of 1,$ [i.e. the entire file]).

See:
:help :!
vs
:help :range!

--
Best,
Ben H

--
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

No comments:

Post a Comment