All Questions
348
questions
339
votes
13
answers
264k
views
vim: how to delete a newline/linefeed character(s)?
Is there a way to delete the newline at the end of a line in Vim, so that the next line is appended to the current line?
For example:
Evaluator<T>():
_bestPos(){
}
I'd like to put this ...
276
votes
12
answers
177k
views
How to run mvim (MacVim) from Terminal?
I have MacVim installed and I am trying to set it up as the editor for Git (version control), but I can't run 'mvim' from the command line as it isn't recognised. How do I setup mvim so I can run it ...
144
votes
11
answers
148k
views
How can I open a Shell inside a Vim Window?
I can open a shell by using the :shell command in Vim, however I can't edit a file and at the same time use the shell.
Is there any way to split Vim in many Windows (or tabs), and have a shell opened ...
101
votes
5
answers
34k
views
How can I make bash tab completion behave like vim tab completion and cycle through matching matches?
I've been meaning to find a solution for this for YEARS.
I am sooo much more productive in vim when manipulating files than bash for this reason.
If I have
file_12390983421
file_12391983421
...
91
votes
5
answers
38k
views
When in Vim insert mode, is there a way to add filepath autocompletion?
I write a lot of shell scripts and I am constantly having to enter in filepaths. I am wondering if anyone knows of a way to get Vim to autocomplete filepaths while in insert mode, just like when you ...
77
votes
5
answers
32k
views
How to run a vim command from the shell command-line?
There are many stackoverflow questions about running shell programs from within vim. Is it is possible to do the reverse, i.e.,
$ vim :BundleInstall
to allow me to run BundleInstall as part of a ...
75
votes
7
answers
46k
views
Vim: Pipe selected text to shell cmd and receive output on vim info/command line
I want to pipe the selected text to a shell command and receive the one-line output from this shell command on the vim info/command line?
What I'm really trying to do: Pipe the selected text to a ...
59
votes
6
answers
38k
views
How to run a series of vim commands from command prompt
I have four text files A.txt, B.txt, C.txt and D.txt
I have to perform a series of vim editing in all these files.
Currently how I am doing is open each files and do the same vim commands one by one.
...
45
votes
5
answers
86k
views
How do you run Vim in Windows?
I just installed gVim, and tried using the usual "vim myfile.java" technique that usually works for linux to open up a file and edit it. But unfortunately, this doesn't seem to work. I've also tried "...
41
votes
11
answers
25k
views
How to write buffer content to stdout?
Is there any chance to write the content of the current vim buffer to stdout?
I'd like to use vim to edit content that was passed via stdin - without the need of a temporary file to retrieve the ...
40
votes
4
answers
8k
views
Execute shell command without filtering from Vim
I want to select a block of text (for example, V%) and use the text as input to a shell command (for example, wc or pbcopy) - but I don't want to alter the current buffer - I just want to see the ...
31
votes
6
answers
27k
views
Vim [compile and] run shortcut
Basically what I want is a keyboard shortcut in vim that lets me [compile and] run the currently being edited C, C++ or Python program. In psuedocode:
when a shortcut key is pressed:
if ...
29
votes
3
answers
7k
views
How do I get vim's :sh command to source my bashrc?
Whenever I start a shell in vim using :sh, it doesn't source my ~/.bashrc file. How can I get it to do this automatically?
29
votes
7
answers
9k
views
What setting in vim counteracts smartindent's refusal to indent # comments in shell scripts?
I recently started using vim 7 (previously vim 6) and the smartindent setting. For the most part, it works well, though I'm so used to typing a tab after an open brace that it is almost counter-...
25
votes
4
answers
13k
views
How to get Cmd-left/right working with iTerm2 and Vim (without requiring .vimrc changes)?
I want to be able to use Option-left and Option-right to skip words (and Cmd-left/right to go to beginning and end of lines) within Vim as it does at my shell prompt. My Iterm2 preferences have ...
23
votes
2
answers
7k
views
How to get return (status) value of an external command in Vim
I want to get the exit value (returned by $? on a shell; usually 0 or 1 for success or failure) of a external shell command in Vim. Note that I want to get its standard output too. So I can use the ...
22
votes
2
answers
11k
views
How to run a shell command through vimscript?
In my Vim setup I'd like to add a configuration that runs a shell command with a certain mapping. Is there any possible way to do this in Vimscript?
20
votes
7
answers
13k
views
How do I launch an editor from a shell script?
I would like my tcsh script to launch an editor (e.g., vi, emacs):
#!/bin/tcsh
vi my_file
This starts up vi with my_file but first displays a warning "Vim: Warning: Output is not to a terminal" and ...
19
votes
3
answers
22k
views
Executing Vim commands in a shell script
I am writing a Bash script that runs a command-line program (Gromacs), saves the results, modifies the input files, and then loops through the process again.
I am trying to use Vim to modify the input ...
14
votes
1
answer
4k
views
vim errors on vim startup when run in fish shell
Here's my error:
~> vim .tmux.conf
Error detected while processing /Users/###/.spf13-vim-3/.vim/bundle/syntastic/plugin/syntastic.vim:
line 23:
E484: Can't open file /var/folders/c4/...
13
votes
6
answers
8k
views
Linux shell (bash) on vi's splitview
I've been searching with no results for an integration of bash inside vi, as featured in emacs; the problem is: I have vi open with 2 views, one open with :split command, and I want to use bash ...
13
votes
3
answers
11k
views
Windows terminal/Console/shell in Vi mode?
I'm a big fan of VIM and I use VI mode for my terminal in Mac/Ubuntu. It's very easy to set a Vi Mode in Unix OS: simply put set editing-mode vi set keymap vi-command into ~/.inputrc.
However, my ...
12
votes
3
answers
2k
views
Running R inside a buffer in Vim
I have used Stata and gVim on Windows for a while now. Recently I have switched to Linux, and I am planning to also change from Stata to R.
A friend of mine is using R and Emacs ESS which seems to ...
11
votes
5
answers
11k
views
Is there a way to change vim's default mode
Does anyone know how to change vim's default mode? Its default mode is command mode, but could I change it to insert mode?
11
votes
2
answers
3k
views
How to remap escape insert mode to 'jk' in fish shell?
I use jk as my escape sequence in vim as well as vi-mode for bash and zshell. How do I do this in fish shell?
i.e. in vim:
inoremap jk <esc>
bash:
bind -m vi-insert '"jk": vi-movement-mode'
...
10
votes
3
answers
6k
views
How to build and run a shell command based on the contents of several lines in Vim?
A frequently used feature of Vim for me is filtering a file (or a selection of text) through an external command and replace the selection with the result, e.g.:
:'<,>'!sort
so
c
b
a
will be ...
10
votes
3
answers
9k
views
shell script to add header to a file
I was trying to write a script to add a trademark header to my .cpp file.
my solution is as follows.
cat trademark.txt test.cpp > new_test.cpp && mv new_test.cpp test.cpp
However, wanted ...
9
votes
2
answers
4k
views
How to check whether shell scripts / Vim running in VS Code integrated terminal?
Issue
Question is as stated in the title.
In gist, I am trying to get my bash scripts and Vim to behave differently when running in VS Code's integrated terminal.
Things I've found
I have managed ...
9
votes
2
answers
855
views
vim: Why does the sh colour scheme highlight `$(...)` as an error?
For example:
I was under the impression that $(...) was recommended over `` because it's easier to nest.
9
votes
2
answers
11k
views
escape character in vim command
I want to run command like this:
vim -c "%g/blablabla/norm /str<ESC>cwSTR" file
How I write escape character in the command?
9
votes
1
answer
2k
views
Best way to read output of shell command
In Vim, What is the best (portable and fast) way to read output of a shell command? This output may be binary and thus contain nulls and (not) have trailing newline which matters. Current solutions I ...
9
votes
2
answers
8k
views
Neovim terminal emulator configuration for Windows 10
I am trying to configure Neovim for Windows. One of the key things of this configuration is getting access to the terminal-emulator (it's very comfortable to switch and use the terminal with Vim). But ...
8
votes
3
answers
13k
views
Compiled vim from source on Mac OSX and getting 'shell returned 127' error?
On my Mac OSX 10.6 machine, I started to use MacVIM for vim. Then I noticed my terminal version was different to the MacVIM version (MacVIM was 7.3 and my terminal version 7.2)... I thought they used ...
8
votes
2
answers
15k
views
Shell commands from vim
What is the best approach of using shell commands from vim? I know about the possibility of !shell_command. But this doesn't know all commands e.g.
export OSTYPE; make install So I have to run it ...
8
votes
1
answer
7k
views
"dyld: Library not loaded", "libruby.1.9.1.dylib" when calling "mvim ." in the command line
I'm trying to open my rails project into mvim (macvim) using "mvim ." but I get the following error.
➜ cs193p git:(master) mvim .
dyld: Library not loaded: /Users/myusername/.rvm/rubies/ruby-1.9.3-...
8
votes
4
answers
13k
views
Vim change block cursor when in insert mode
Not sure what the terminology is for it but on Vim the 'cursor' is always like an insert/replace cursor instead of the blinking line cursor I'm used to in other gui editors. Is there any way to change ...
8
votes
2
answers
11k
views
Running a shell script in .vimrc (and processing the output)
I am trying to run a shell script from within a .vimrc file (three problems marked in the script):
function! CheckMe(file)
let shellcmd = 'checkme '.a:file
" Start the command and return 0 ...
8
votes
2
answers
4k
views
how to set vimrc tags to use shell environment variables
I tried but failed and need an expert help. In a .vimrc I have the following:
set tags=/sandbox/myNameIsSam/tags
This works just fine. Inside gvim, I can load the tags file and everything is awesome....
7
votes
1
answer
2k
views
Im using vim to check man page, and there is some weird character,how to make it normal?
I'm trying using
man ascii | vi -
to check ascii manual with vim,
then there are some weird character like '^H'
weird character in vim
how to make it normal?
EDIT:
i think this is due to some ...
7
votes
1
answer
659
views
How to map a long bash command in vim?
The shell command can kill chrome process.
ps -ef | grep chrome |awk '{print $2}'| xargs kill
Now I want to map the character - with above bash command.
nnoremap - :!ps -ef | grep chrome |awk '{...
7
votes
1
answer
4k
views
How do I get Code Folding in Vim for shell scripts working
Whatever I do, I don't seem to get syntax folding running for shell scripts.
So I have a file called abc.sh call
:let g:sh_fold_enabled=7
:let g:is_bash=1
:set foldmethod=syntax
But it still can't ...
7
votes
2
answers
3k
views
Next Line in less
I'm using less and since I have long lines I need some way of going to the next line (I mean the real next line, not the next line shown in less which might be the continuation of the previous line)
...
7
votes
4
answers
6k
views
IDE that provide autocompletion and error detection for Linux bash or shell scripting?
Our dev team is looking for an IDE like vi or nano or even textpad for windows that has the capability to autocomplete and error correction for bash or shell script for linux. Basically something ...
7
votes
1
answer
3k
views
How do I send the current buffer or line as stdin to system() in vim?
There are 3 closely related vim commands that let you call an external program:
:[range]!{filter-cmd} {arg} (ex-command, :help :range!)
:[range]write !{cmd} (ex-command, :help :w_c)
system({expr}, {...
7
votes
7
answers
3k
views
Pipe a vim command after a shell command
I'm trying to make a key mapping in vim that (a) saves current file (b) performs a git action, using shell (c) quits current vim editor.
I've tried the following methods but still can't figure it out....
7
votes
1
answer
3k
views
Most elegant way to detect available colors in terminal to use colorschemes in vim?
I want to know if it's possible to detect available colors in terminal which vim was called, so I could select different colorschemes for each color situation.
This is different from checking &...
7
votes
5
answers
5k
views
Run a command but stay in the shell vs exit
I know that in vim I can type
:terminal <command> %
to run a command on the file in the current edit buffer. For example and to simplify what I want to do let's take a simple ls command:
:...
7
votes
1
answer
3k
views
Run shell command on visual selection
I'm trying to run a shell command on a visual selection but I can't figure out
how to run it on the selection and not the selected lines, eg:
Selection start here
v
hello
world
^ Ends ...
6
votes
3
answers
2k
views
Vim: read modeline after opening the file?
I work on a variety of projects and many of them set file-specific vim settings. I have been asked to not have modelines set in .vimrc; is there a way after loading the file to load the modelines ...
6
votes
3
answers
4k
views
Killing vim processes with a shell script leaves .swp files
I developed a script that will kill all 'vim' processes working on
xxx.log files:
ps -ef|grep vim|grep xxx.log|awk '{print $2}'|xargs kill -9
However, the .swp (swap) files remain for each vim ...