Gvim shell problem - vim

I have been using Gvim for quite sometime and I like it very much.
There is a problem I am facing with Gvim.
I type "shell" and go to the command line, When I press the up arrow I get some weird
symbols and I am not able to use backspace also.
The version which I am using.
VIM - Vi IMproved 7.2 (2008 Aug 9, compiled Mar 19 2009 15:27:51)

Sadly the reason this is not working is because gvim is an editor, not a terminal emulator. When yoy type :shell in gvim, you do not actually get a shell, you get some weak shell emulation. I say 'weak' because that shell emulation does not know how to deal with color codes, clear the screen or much else.
I stick to terminal vim, that way I can either use :shell, or, as is much more common, ^Z to just drop back into my shell to do something ( ^Z == suspend ) That, plus gnu-screen, plus a good shell is all the IDE I want.

Try some wrappers, e.g. Conque Shell : Run interactive commands inside a Vim buffer ;)

vim is not for such complicated things I think. you can do simple shell operation via :! or :shell, However, vim is only a good if not best editor.
What you need can be done in shell-mode of Emacs.

Related

Freeing Terminal While Using gVim

Is there a way that I can free my terminal from running the gVim process w/o quitting gVim so that I can continue to use the terminal? I'd like to be able to
do something similar to what I do with emacs. With emacs I can either use the emacs [file] command to have the process run through the terminal, or I can use the runemacs [file] command to keep the terminal free.
I start gVim with the command:
gvim [file]
and then the terminal hangs until I :quit gVim. When I searched for an answer to this question on the web, people advised that the best thing to do was to use ctrl-z to suspend the vim process and then use fg to return. However, this fails to work for me in both command line and gVim mode. I'm using Git Bash for my terminal on Windows 7.
You could run gvim in background as any other process:
gvim [file] &
After executing this command you receive a message indicating the pid of the new process. When you end it you should receive a similar message on that shell.
Edit:
The ctrl-z/fg problem is probably related to windows. This question states that GitBash would create a new shell instead of returning to the current one, so it probably doesn't work as in Linux. A possible solution would be to run your commands from gVim, either calling the shell through :! on mappings, or plugins/commands (fugitive for git, :py or some plugin for python interpreter, etc).

Mark mode in Terminal without mouse

Is it possible to enter mark mode(to mark text in Linux terminal) without mouse. In CMD you can ,alt+space+e+k. Can it be done natively without 3th party programs?
Regardless of your terminal you can enable vi mode for you shell, both bash and zsh support this.
A quick one (without installing third party programs) would be to set -o vi in your shell to enable vi and use the shortcuts
If you don't like it you can always come back to emacs: set -o emacs

Run emacs as separate process from terminal

When I run the emacs text editor the process does not return so I cannot use the terminal which is obviously the default behavior.
I cannot find the switch or command in the man but I know it is something very simple.
How can I run emacs as a separate process so I can continue to use the terminal without opening a second one?
You can start any program in the background by appending an ampersand to the command, emacs &.
There's a whole framework for working with backgrounded processes, see for example man jobs, disown, fg, bg, and try Ctrl-Z on a running process, which will suspend it and give you the terminal, allowing you to resume that process either in the foreground or background at your pleasure. Normally when your shell closes, all those programs will end, disown allows you to tell a program to keep running after you end your session.
The emacs --help command is giving you a tip:
--batch do not do interactive display; implies -q
So run emacs --batch (or maybe emacs --executesomecommand ).
If you have a desktop (or some X11 display) and want emacs to open an X11 windows and give you back a shell prompt, run it in the background (e.g. emacs &) as many commented.
And I find very useful to start programs (or shells) within emacs, e.g. with Emacs commands: M-x shell, or M-x compile (for make etc...), or M-x gdb for a debugger.
You usually start one single emacs at the beginning of a working day. You could use emacsclient (or set your EDITOR environment variable to it) for other editions using the same emacs.
I'd like to add that Windows does have an equivalent to *nix's & for starting programs in a separate process:
start /b emacs Main.hs

How do I use Vim with Rebar

Trying to get up and running Vim + Rebar.
Separately they work but not together. What I want to achieve is to run eunit without leaving the Vim.
I guess this is doable with following plugin https://github.com/mbbx6spp/vim-rebar . Unfortunately is very poorly documented.
How do I run my tests quickly, see the output, code and once again.
All your feedback will be appreciated.
I don't know how to integrate rebar into vim, but perhaps you could try tmux? This works for me. In one window I keep opened vim, another window i use as compilation/attach session to erlang node.
One quick way to get out of Vim is to suspend it with Ctrl+z, run your commands, and then foreground it again with fg afterwards. Works at least on bash in Os X and Ubuntu Linux.
You can also run command line commands with :! <command name> directly from Vim, e.g. :! ls.
Yet another way is to use screen, with one window running vim and another still on the command line.
The best solution I've found is to use a Makefile in my project. Since vim is capable of running shell commands, you can call make & have it use your makefile. Then map these shell commands to shortcuts of your choosing.
For example, my Makefile has the following:
test:
$(REBAR) skip_deps=true eunit
In my .vimrc:
command MakeErlangTest !make test
nmap <leader>r :MakeErlangTest<CR>

Enable colored output in mvim

I'm running rspec from within mvim with :!rspec spec/lib, however if I include --color flag, I get
[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m[32m.[0m
Finished in 0.01708 seconds
[32m7 examples, 0 failures[
I tried --tty flag which works with rstakeout, but no help.
Unfortunately this is not possible.
MacVim does it's own graphics rendering, which is not implemented as/via a terminal emulator, so it has no concept of ANSI color codes etc. I believe I remember the author of MacVim commenting that this will never be supported, which is a shame.
When I was using MacVim, I'd run rspec --no-color to at least avoid the escape sequences cluttering the output.
I've since switched to vim (running inside tmux in full-screen iTerm2) and it's nice to get back the color output of console commands.

Resources