All Questions
615
questions
118
votes
5
answers
26k
views
How to make .bashrc aliases available within a vim shell command? (:!...)
I use bash on mac and one of the aliases is like this
alias gitlog='git --no-pager log -n 20 --pretty=format:%h%x09%an%x09%ad%x09%s --date=short --no-merges'
However when I do
:! gitlog
I get
/...
105
votes
4
answers
65k
views
VIM: how to go to exact line on Ubuntu
I'm using vi on Ubuntu 12.10. Some files are quite long so when I want to go to the middle of the file, I have to page down or scroll down.
Is there a VIM shortcut to go to an exact line number?
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
...
92
votes
13
answers
85k
views
How to highlight Bash scripts in Vim?
My Vim editor auto highlights PHP files (vim file.php), HTML files (vim file.html) and so on.
But when I type: vim file and inside it write a Bash script, it doesn't highlight it.
How can I tell Vim ...
85
votes
7
answers
32k
views
Execute current line in Bash from Vim
This question is similar to Vim: execute current file?, but instead of executing the current file I want to execute only the current line.
Is this possible?
Ideally, I am looking for solutions which ...
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 ...
52
votes
3
answers
28k
views
Strange behavior of vim color inside screen with 256 colors
I was trying to make the syntax highlighting (with 256 colors) of vim work inside screen, which is running inside gterm.
It works quite fine in the beginning. What I mean by "in the beginning" is, ...
51
votes
4
answers
114k
views
Reload .Xresources without restarting the xterm
To use ALT key in vim without tweaking, the escaping should be disabled in xterm.
Without escaping the ALT will not work in bash for shortcuts.
to work around I need to reload this option before ...
45
votes
6
answers
43k
views
Open files in existing Gvim in multiple (new) tabs
I have put some aliases in my .bashrc to open a group of project files in gvim, each in their own tab:
gvim -p <list of file names using absolute paths>
This is all well and good, except there ...
42
votes
9
answers
51k
views
Unable to change the default editor in the terminal
My default editor is Pico at my server. I use Bash and Linux.
I tried to change Vim to be my default editor unsuccessfully by:
echo vim > $EDITOR
How can I change Vim to be my default editor?
The ...
42
votes
6
answers
10k
views
Sorting words (not lines) in VIM
The built-in VIM :sort command sorts lines of text. I want to sort words in a single line, e.g. transform the line
b a d c e f
to
a b c d e f
Currently I accomplish this by selecting the line and ...
42
votes
4
answers
8k
views
How to make Vim detect filetype from the shebang line?
Sometimes I write scripts without any filename extension. For example:
#!/usr/bin/env node
console.log('hello world!');
I hope that Vim can detect the filetype from the shebang line (e.g. #!/usr/...
38
votes
11
answers
28k
views
How to "copy to clipboard" in vim of Bash on Windows? [closed]
I used to use "+y to copy text to system's clipboard, but it doesn't work in vim of Bash on Windows.
37
votes
5
answers
50k
views
Bash: Kill Vim when "Vim: Warning: Output not to a terminal"
Every once in awhile I make a mistake at the command line, and use vim in a subshell.
This of course locks up that terminal window, and outputs a bunch of errors, with the main error being
Vim: ...
33
votes
1
answer
6k
views
map jj to Esc in inputrc (readline)
How can I map jj to Esc in inputrc so it gets picked up by apps using GNU Readline (python, mongoshell, ...)
all works fine on zsh using:
bindkey -M viins 'jj' vi-cmd-mode
this is my current ...
31
votes
3
answers
10k
views
How to run spell check on multiple files and display any incorrect words in shell script?
I have a few files I wish to spellcheck. Normally I would open these in vim, run :set spell and do the changes. It's really teadious to open files and manually check if I've misspelt any words since ...
30
votes
4
answers
29k
views
Git-commit unable to open vim
Recently I installed bash-it into my terminal. Now, when I try to execute git commit the terminal shows me this error:
/usr/bin/mate -w: /usr/bin/mate: No such file or directory
error: cannot run /...
28
votes
2
answers
14k
views
Bash's vim mode, not vi
I was fascinated when I discovered vi-like bash's editing mode. One can easily toggle it by issuing set -o vi command. But is there any way to toggle vim-like mode?
I mean when you are in a vi-like ...
26
votes
8
answers
11k
views
Why vim is changing first letter to g after opening a file
When I open a file, eg vim .bashrc, vim opens the file and change the first letter to g. What I see is the following:
g To the extent possible under law, the author(s) have dedicated all
# copyright ...
25
votes
7
answers
12k
views
Save file as root after editing as non-root
Ok so this happens to me all the time. There has to be a better solution. Let's say you do vim /etc/somefile.conf and then you do i but realize you are not sudo and you can't write. So then I lose my ...
23
votes
1
answer
23k
views
What does an arrow mean when listing files? [closed]
I am listing hidden files:
ls -ld .?*
And I get an output:
drwxrwxr-x 3 kisco kisco 4096 Jun 18 19:41 .shutter
drwx------ 6 kisco kisco 4096 Jun 17 11:07 .Skype
-rw------- 1 kisco kisco ...
22
votes
5
answers
9k
views
get bash history to vi
When I try to read bash history into vim, I get nothing.
:r !history
If I just execute the command, i.e.
:!history
instead of history I get a snapshot of my terminal as it looked before I started ...
22
votes
3
answers
17k
views
How do you source neovim config file without restarting nvim?
Is there a way to source the ~/.config/nvim/init.vim file from within nvim?
With vanilla vim you can source .vimrc with :so % : Is there an equivalent method do with similarly in neovim?
21
votes
4
answers
9k
views
Vim not recognizing aliases when in interactive mode?
Same question as this, however the solution there didn't work.
I set these variables in my ~/.vimrc:
set shellcmdflag=-ic
set shell=/bin/bash\ -i
and I have an alias in my ~/.bash_aliases:
rgr() { ...
21
votes
3
answers
19k
views
Set runtimepath, adding a directory from an expression in vim?
Inn ~/script.vim, I have:
set runtimepath+=string(substitute(expand("%:p"), 'script\.vim', '', 'g'))
I have an alias in .bashrc:
alias vimscript="vim -S ~/script.vim"
Running string(substitute(...
19
votes
4
answers
8k
views
How to open all modified files with git?
How to open all deleted, modified, and created files since the last git commit, I tried using git status first, but it was difficult to parse, so I found git status --porcelain was easier to parse 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 ...
19
votes
2
answers
2k
views
leave vim split window in insert mode
I want to view the output of a bash command in a vim split window :split. To this end I installed "Conque Shell" which displays bash in a split window upon :ConqueTermSplit bash. I can then run my ...
19
votes
3
answers
2k
views
Send code from Vim to an external application for execution
Using Stata my text editor is gVim. Using scripts from here and here to send code from Vim to Stata keeps me from switching to Linux. The scripts are in AutoIt I cannot use in Linux. They are ...
18
votes
6
answers
75k
views
copy and paste in vi
I don't have a huge amount of experience using VI. I am running it on Mac OSX.
I've copied and pasted text before in the editor using (when I say gui in the following I mean the Mac OSX gui)
Cursor ...
17
votes
5
answers
34k
views
Open Vim from within a Bash shell script
I want to write a Bash shell script that does the following:
Opens a file using Vim;
Writes something into the file;
Saves the file and exits.
echo 'About to open a file'
vim file.txt # I need to ...
16
votes
3
answers
3k
views
Vi keybindings for R command line like in Bash
Context
I like editing and manipulating the bash command line using vi-style key bindings with the following setting:
set -o vi
However, when I start R on the command-line, these keybindings ...
16
votes
2
answers
9k
views
vim red highlight $( )
I was writing a script when I decided to move the functions to a lib file, but when I open the lib file all the $( and the consecutive ) are red highlighted, here are some examples of the script
TAB="...
15
votes
5
answers
4k
views
How to make the vim call function in .bashrc?
Environment: debian9+vim7.4.
cat .bashrc
add(){
echo $(expr $1 + $2)
}
Now edit a file in vim
add 1 5
Run it in command mode :w !bash,an error occur.
bash: line 1: add: ...
14
votes
4
answers
5k
views
Force bash to use .vimrc in vi mode
Bash can be set to operate in vim mode . However, my .vimrc is no longer used. Specifically, my mapping of jj to Esc no longer works. I have to press Esc to exit to insert mode. How do I tell bash to ...
13
votes
4
answers
14k
views
Enable vi mouse wheel scrolling using bash on ubuntu on windows 10
I'm using bash on ubuntu on windows 10 and would like to enable scrolling using the mouse wheel in vi or vim. I've tried entering the following command in vim and added it to the .vimrc file and /usr/...
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
1k
views
Background and foreground bash/zsh jobs without adding newlines in "continued/suspended" messages
I have a process that goes something like this:
Run a command that generates a bunch of results in a bunch of files
Open a file in vim
Edit one of the results
Background vim, get the next result, ...
12
votes
5
answers
13k
views
How can I count the number of words in a directory recursively?
I'm trying to calculate the number of words written in a project. There are a few levels of folders and lots of text files within them.
Can anyone help me find out a quick way to do this?
bash or ...
12
votes
4
answers
13k
views
Vim - Capture strings on Search and use on Replace
I have a css selector such as:
#page-site-index .toolbar .items {
How do I capture the ".toolbar .items" part and use it on Replace part of Vim S&R, so this selector can turn into:
#page-site-...
12
votes
2
answers
30k
views
How do I deal with vim's swap file system?
When using vim in ubuntu, I accidentally pressed ctrl-z which suspended my session of vim. I was editing a file (I'll call it test) which was not saved.
When I opened the file again in vim, I got the ...
12
votes
4
answers
56k
views
How to add new line in bashrc file in ubuntu?
I'm trying to update my bashrc file in ubuntu with some environment variables.
I can do this using below command.
echo 'export APP=/opt/tinyos-2.x/apps' >> ~/.bashrc
But I want to do it ...
11
votes
3
answers
2k
views
Why doesn't "history | vim" work?
I want to use the Vim to see the result of history (not in the shell). I think history | vim will work (use the result of history as the input of vim), but it returns with:
$history | vim
Vim: ...
11
votes
5
answers
4k
views
vim/vi/sed: Act on a certain number of lines from the end of the file
Just as we can delete (or substitute, or yank, etc.) the 4th to 6th lines from the beginning of a file in vim:
:4,6d
I'd like to delete (or substitute, or yank, etc.) the 4th last to the 6th lines ...
11
votes
1
answer
1k
views
Why does ""Here strings" in bash changes the syntax color of whatever follows it?
I am writing a bash script which uses here strings (<<<), please see example below. The script works fine and gives expected output, but the problem is that the (vim) editor syntax color is ...
11
votes
2
answers
5k
views
Vim syntax for getting name of current file
In Vim, I can echo the current filename using this command:
:echo @%
I found that information here: http://vim.wikia.com/wiki/Get_the_name_of_the_current_file
Can someone explain why the @ symbol ...
11
votes
4
answers
6k
views
Find files with grep and open in editor
I'd like to use grep for searching through a directory and open the files with matches in an editor of choice. (emacs or vim will do.)
I can open the first match via vim $(\grep -l "static void main" ...
11
votes
1
answer
2k
views
.vimrc action onclose
is it possible to use something like an "vim-close/exit"-Event to execute some last commands before vim quits?
I use this lines in my config, to let vim set my screen-title:
if $TERM=='xterm-color'...
11
votes
2
answers
3k
views
Zshell aliases like !gst inside vim?
Is there a way to run my zshell aliases inside vim, with the output going to a new split?
I'm using oh-my-zsh's git aliases like gst, and I am unable to do :!gst inside vim.
Thanks
11
votes
4
answers
8k
views
Executing Bash functions from within Vim - how can I do it? [duplicate]
Possible Duplicate:
Commands executed from vim are not recognizing bash command aliases
I have the following function in my ~/.bashrc file (on my Ubunut box)
# convert tex to pdf, no bib
...