Re: vim with shell
On 2007-02-24, Subramanian Ramaswamy <[EMAIL PROTECTED]> wrote: > (2) My terminal is in vi mode, since that makes me the most productive > i.e. I have set set -o vi in my .bashrc. > How can one enable this mode within vim's ":" or shell "!" commands - > this will be very useful, if I can navigate that with vi commands... If I understand your question correctly, you can't do that while editing the command line itself, but you can use vi commands to edit the command line in the command window. See :help cmdwin I also have this in my ~/.vimrc so that typing on the vim command line behaves similarly to typing on the shell command line. set cedit= HTH, Gary -- Gary Johnson | Agilent Technologies [EMAIL PROTECTED] | Wireless Division | Spokane, Washington, USA
Re: vim with shell
On 2/24/07, Subramanian Ramaswamy <[EMAIL PROTECTED]> wrote: Thanks, that solves the first half of the question. Any inputs on how to set something like "set -o vi" within the vim shell? Try one of these: 1. export SHELLOPTS=:vi: # in your .bashrc or 2. let $SHELLOPTS="vi" -- in your .vimrc See man bash, search for SHELLOPTS. Yakov Thanks. On Sat, 24 Feb 2007 12:58:28 -0500, Yakov Lerner <[EMAIL PROTECTED]> wrote: > On 2/24/07, Subramanian Ramaswamy <[EMAIL PROTECTED]> wrote: >> Hi all, >> >> >> I have two questions regarding the shell (invoked using "!") in vim: >> (1) Is it possible for the shell to remember what commands I executed in >> the original shell window in addition to the commands executed within >> the >> vim shell window? >> e.g. >> I open up a terminal and type >> $asdfasfasd.long command >> Now, I open up vim >> $ vim main.c >> Within vim when I invoke the shell, can I make it remember >> "asdfasfasd.long command", in addition to all the vim shell commands >> that were previously executed? >> >> (2) My terminal is in vi mode, since that makes me the most productive >> i.e. I have set set -o vi in my .bashrc. >> How can one enable this mode within vim's ":" or shell "!" commands - >> this will be very useful, if I can navigate that with vi commands... > > This is possible as I describe below. But you'll need to write > some amount of vimscript code. > You'll need to impement the following sequence: > > 1. define the 'vim' as following bash alias: > alias vim='history | tail -20 >~/.cmds; vim' # save shell command > history so > # that > vim can access it later > 2. put this alias into your ~/.bashrc > 3. In your .vimrc, check that file ~/.cmds exist. > Read the file line-by-line, and add the lines into vim > command history using function > histadd(). See :help histadd() > > You'll probably be the only user of this trick( when I need something > like this, I use > cut-end-paste, or storing commands to 1-liner temp files). > > Yakov
Re: vim with shell
Subramanian Ramaswamy wrote: Thanks, that solves the first half of the question. Any inputs on how to set something like "set -o vi" within the vim shell? Thanks. I guess you would have to write it into one of the scripts which non-interactive non-login shells source at startup (see the manpage for your shell to get the names of these scripts). Best regards, Tony. -- Computers are useless. They can only give you answers. -- Pablo Picasso
Re: vim with shell
Thanks, that solves the first half of the question. Any inputs on how to set something like "set -o vi" within the vim shell? Thanks. On Sat, 24 Feb 2007 12:58:28 -0500, Yakov Lerner <[EMAIL PROTECTED]> wrote: On 2/24/07, Subramanian Ramaswamy <[EMAIL PROTECTED]> wrote: Hi all, I have two questions regarding the shell (invoked using "!") in vim: (1) Is it possible for the shell to remember what commands I executed in the original shell window in addition to the commands executed within the vim shell window? e.g. I open up a terminal and type $asdfasfasd.long command Now, I open up vim $ vim main.c Within vim when I invoke the shell, can I make it remember "asdfasfasd.long command", in addition to all the vim shell commands that were previously executed? (2) My terminal is in vi mode, since that makes me the most productive i.e. I have set set -o vi in my .bashrc. How can one enable this mode within vim's ":" or shell "!" commands - this will be very useful, if I can navigate that with vi commands... This is possible as I describe below. But you'll need to write some amount of vimscript code. You'll need to impement the following sequence: 1. define the 'vim' as following bash alias: alias vim='history | tail -20 >~/.cmds; vim' # save shell command history so # that vim can access it later 2. put this alias into your ~/.bashrc 3. In your .vimrc, check that file ~/.cmds exist. Read the file line-by-line, and add the lines into vim command history using function histadd(). See :help histadd() You'll probably be the only user of this trick( when I need something like this, I use cut-end-paste, or storing commands to 1-liner temp files). Yakov
Re: vim with shell
On 2/24/07, Subramanian Ramaswamy <[EMAIL PROTECTED]> wrote: Hi all, I have two questions regarding the shell (invoked using "!") in vim: (1) Is it possible for the shell to remember what commands I executed in the original shell window in addition to the commands executed within the vim shell window? e.g. I open up a terminal and type $asdfasfasd.long command Now, I open up vim $ vim main.c Within vim when I invoke the shell, can I make it remember "asdfasfasd.long command", in addition to all the vim shell commands that were previously executed? (2) My terminal is in vi mode, since that makes me the most productive i.e. I have set set -o vi in my .bashrc. How can one enable this mode within vim's ":" or shell "!" commands - this will be very useful, if I can navigate that with vi commands... This is possible as I describe below. But you'll need to write some amount of vimscript code. You'll need to impement the following sequence: 1. define the 'vim' as following bash alias: alias vim='history | tail -20 >~/.cmds; vim' # save shell command history so # that vim can access it later 2. put this alias into your ~/.bashrc 3. In your .vimrc, check that file ~/.cmds exist. Read the file line-by-line, and add the lines into vim command history using function histadd(). See :help histadd() You'll probably be the only user of this trick( when I need something like this, I use cut-end-paste, or storing commands to 1-liner temp files). Yakov