Questions tagged [vim]
Vim is a highly configurable text editor built to enable efficient text editing. It is an improved version of the vi editor.
3,715
questions
10
votes
3
answers
12k
views
How can you switch the j and k keys in vim?
Is there any way to map the k key to 'down' and the j key to 'up'? This seems much more intuitive to me, since the right arrow will also move the cursor down, if it's at the end of the line.
Why was ...
0
votes
1
answer
62
views
gVim updates the title text field when the window is made narrower - can I stop this handy behavior?
Depending on the width of the GUI window, gVim 9.0 on Windows 10 (maybe Win 11 as well) would decide to be creative with the title text of the window, and show any of the following when I review my ...
8
votes
3
answers
4k
views
Abort a vim paste
Sometimes I paste a lot of data into vim (>5000 rows) and forget to enable paste mode. In that case, vim is busy for several minutes, trying to correctly indent all the text (which gets REALLY bad ...
11
votes
3
answers
3k
views
Vim file name completion relative to current file
In Vim, when I am in insert mode, and I want to use file-name completion, I want the search path to be relative to the current file, not the current working directory. For instance, if in insert mode ...
4
votes
2
answers
5k
views
How do I select the text from cursor to white space with vi script?
expand('<cword>')
The above can select the word from cursor, but I want to select more, that is the text delimited by the cursor and the first white space.
How to do that in vim script?
...
4
votes
3
answers
3k
views
expanding current directory in NERDTree without changing root
Is there a way to make NERDTree expand to display the current file's directory - without messing with the working directory or changing the tree root?
So when working with baz.ext, it should look ...
7
votes
5
answers
5k
views
Customize text editor and terminal to use non-monospaced fonts without the horrible results?
I want to experiment with all fonts, including those that aren't mono-spaced. I understand the reason for using monospaced fonts, but frankly they don't seem legitimate to me.
For instance, one ...
63
votes
5
answers
186k
views
How to use vimtutor?
Someone recommended me that I should use vimtutor to learn the basics of vim. But I have no idea how to use it. Is it an application? A website?
This is the only link that was given during the ...
20
votes
4
answers
7k
views
Getting CTRL+V to work in Vim inside Conemu
Conemu uses CTRL+V as the short cut to “paste first line of clipboad.” I want this functionality when I’m interacting with the command-line, but when I’m in Vim I’d like Vim to handle it.
3
votes
2
answers
2k
views
Vimium browsing with textfields and different scrollable elements
I'm using vimium:
https://chrome.google.com/webstore/detail/vimium/dbepggeogbaibhgnhhndojpepiihcmeb
It's a way to browse / navigate with a keyboard.
I generally love it but I don't know how to ...
5
votes
1
answer
10k
views
How to delete everything after every a specified word in vim
so i have this string
fruit banana
fruit apple
fruit grape
planet jupiter
planet mars
planet saturn
And I want to change those string to like this
fruit
fruit
fruit
planet jupiter
planet mars
planet ...
2
votes
4
answers
843
views
Why does d + down delete two lines in Vim?
This behavior is consistent across all environments where I have used Vim (Cygwin, Putty, VC, xterm & co). I realize that it has something to do with the way input is read and the representaion of ...
1
vote
1
answer
28
views
Save file with a generated name from vim command mode
I am trying to save file with a generated name from vim command mode. I am using the command:
:w !tee"/tmp/vim/$(date +'%s').tmp"
But it throws me an error that filename cannot be empty. Am ...
0
votes
1
answer
1k
views
How to pipe vim clipboard through tmux?
I noticed when using VIM through the terminal, I can easily copy a line of text to my system clipboard using the clipboard register like V"+y (that is, then paste that text to some other window ...
3
votes
6
answers
6k
views
How to find the line with the maximum number of columns/characters in Vim/gVim?
I'm currently using gVim on Windows XP, and I have 2 follow-ups to my core question:
What is the best method of finding the line with the most characters?
My current method: I use the regex search :/...
9
votes
2
answers
4k
views
tmux in zsh with vi mode, toggle cursor shape between normal and insert mode
(note: I wrote this question on stackoverflow, but got flagged as offtopic, so I'm re-writing it here)
Here's what I want:
Consistent behavior (as much as possible) between Vim, MacVim, zsh with vi-...
118
votes
4
answers
110k
views
How to add a command in vim editor?
If suppose my source code file name is "foo.c".
While editing and debugging i always execute this command:-
:!gcc -g foo.c -o foo;gdb foo
Can I add a custom command to Vim such that If i type ":...
46
votes
5
answers
20k
views
How can I discard file change from fugitives status window?
When in the fugitive-plugin status window, accessed using :Git, it's possible to diff changes for a file using D and toggle files for commit using -.
Is there any similar shortcut for discarding ...
0
votes
1
answer
217
views
bash: XY: command not found; when XY is an existing alias
I've just noticed that when I call fc, I got the following error message:
zoltan@adrian ~ $ fc
bash: vi: command not found
The which command returns a similar result:
zoltan@adrian ~ $ which vi
which:...
0
votes
2
answers
1k
views
How does vim set indentation for json files?
Other files, like .c, .cpp, .java, etc., I like to indent 4 spaces, but with only .json files, I like to indent 2 spaces.
How can I configure vim for this purpose?
I know it's possible to do :!%jq . ...
1
vote
2
answers
641
views
MacVim - how to make mouse based selection be "visual mode"?
Sometimes I select text in vim using the mouse.
I'd like that selection to be treated the same as a visual mode selection, so I can immediately start running commands against it.
Is there a way I ...
3
votes
2
answers
1k
views
Vim NERDTree not working
Encountered a strange bug. I cannot open directories/files in NERDTree when I double click or press o. Any help is appreciated.
2
votes
2
answers
1k
views
Not able to map any keys between F1 to F5 in gvim
I am not able to map any keys between F1 to F5 in gvim through vimrc. However all the keys after F5 are being properly mapped.
Here is my vimrc file content.
map <F1> :q!<ESC>
map <...
0
votes
1
answer
181
views
How to type in ASCII ESC in vim/Linux using remote terminal tool
ENV = Centos7, bash version 4.2.46
Main Goal -
I want ANSI color codes to display colors instead of actual codes when using cat or tail.
Current Status -
If sample.txt contains codes as below
\e[32m ...
10
votes
9
answers
7k
views
Use of hash (#) on OS X with UK MacBook Pro
I have MacVim on a UK MacBook Pro. I can use the hash on TextMate by typing alt 3 but in vim this does not work. Do you know how I can type a hash using VIM on a UK MacBook Pro?
The problem is ...
1
vote
2
answers
220
views
autocmd behaviour not as expected
I'm trying to set hlsearch on by default when I enter a buffer in vim.
Running :set hls manually upon entering a buffer performs the action I expect. However, when I add autocmd BufEnter * set hls to ...
0
votes
1
answer
39
views
How to permanently remap petadactyl keys
Using pentadactyl extension for firefox, how can I persistently change a key mapping. For example, how could I change shift+j to go to the next tab next time I open the browser? The command map J gt ...
6
votes
1
answer
9k
views
Coc nvim suggestion selection
I have installed the plugin and also I can see the suggestions. But I am unable to select it I have tried enter, tab, space but still I can’t select it. I have to complete it myself and it is really ...
38
votes
2
answers
19k
views
In Vim, what are settings/commands that begin with a prefix (b:, g:)?
I installed this plugin with Vundle and noticed that it has some settings (the README calls them variables) like:
b:javascript_fold
and
g:javascript_conceal
The README says I, "can add them to ...
3
votes
0
answers
115
views
tmux send-keys to vim has no effect if used along with swap-pane
I have a tmux window with 2 panes (pane-ids: 0 and 1). In the pane 0 there is vim launched. I want to fire a combination of two commands from tmux command-prompt:
:send-keys -t 0 "iabc" ; ...
2
votes
1
answer
376
views
How to expand tabs to spaces, but only for visual aid only
I am starting with a new project with a lot of legacy code in C and Golang
The developers there are adamant on using tab :P and enforce 80 column limit
I am not a fan of tabs and am having hard time ...
1
vote
1
answer
1k
views
How to have neovim open a new pane in tmux without switching to it?
This command allows for a new pane to open:
:silent !tmux split-window -h<CR>
But the problem is that my cursor switches to the new pane and I am forced to switch back. How do I turn off the ...
0
votes
0
answers
105
views
Can FIGNORE be limited to specific applications?
I know that you can use FIGNORE to remove filename completion from suffixes.
For example, to avoid a lot of garbage files produced by LaTeX, I've been using:
FIGNORE=bst:aux:bbl:blg:pdf:fls:...
8
votes
2
answers
12k
views
Highlight the character the cursor is on in vim
How can I highlight the cursor in vim? I am interested in highlighting only the letter that the cursor is in.
Using:
set cursorcolumn
highlight CursorColumn guibg=lightblue ctermbg=lightgray
...
1
vote
2
answers
6k
views
How can I configure shortcut keys in all modes of vim?
I want to configure a shortcut key that can be used in both edit mode and normal mode, usually two commands are required:
:nnoremap <C-s> :w<cr>
:inoremap <C-s> <esc>:w<cr&...
0
votes
0
answers
102
views
in vim, after renaming the file, swap file exists, it is a pity to delete old swap file
After renaming the edited file and after recovery is ok, vim gives the recommendation to delete the old swap file.
That can easily be done. And all works fine. But it is a pity to do so.
The old swap ...
-2
votes
1
answer
1k
views
Error: Too many arguments (need at most 2) when installing tmux plugins
I'm trying to install the tmux-logging plugin. So I:
Cloned tmux-plugins/tmux-logging from Github.
Created conf file ~/.tmux.conf.
Added run-shell ~/clone/path/logging.tmux to bottom of the config ...
3
votes
2
answers
430
views
Vim case-sensitive filename completion on Mac
How can I make Vim's filename completion case-sensitive?
The following behavior is very annoying: If I type liTab (all lowercase), Vim completes to LICENSES, but what I really want is to complete to ...
10
votes
2
answers
4k
views
Create a file under the cursor in Vim
I have a list of files
file1.ext
file2.ext
...
How do I create a file with file2.ext name if my cursor is inside file2.ext. Kind of like gf only for creating new files (this is a hypothetical ...
0
votes
1
answer
4k
views
vimtutor: command not found
My first time trying to pull up vimtutor fails. I get a vimtutor: command not found message. Strangely, running vim works fine.
I've never installed Vim on my own, I just found it working when I type ...
0
votes
1
answer
37
views
open file with non-default colorscheme using vim
I used to know an option to add when using vim which would open the editor using the specified color. I don't want to permanently change the color system-wide, but rather use an alias to open a file ...
4
votes
1
answer
3k
views
Cygwin vim doesnt show 256 colors under ConEMu
When using cygwin vim under ConEmu, the default vim theme doesnt display correctly after I set t_Co=256.
This is how ConEmu looks after the command: http://postimg.org/image/g6g98exbx/
My .vimrc:
...
3
votes
3
answers
3k
views
Home and End keys don't work in putty + vim + xterm
I'm using putty to ssh to Ubuntu with TERM=xterm-256color.
Inside vim, the home and end keys are not working properly. "Home" key makes vim enter in "Insert" mode and put a 'w' character. Similarly "...
95
votes
9
answers
70k
views
Can I disable continuation of comments to the next line in Vim?
In Vim, if I'm typing a comment in a code file, and I hit Enter, it automatically makes the newline a comment, too.
For instance, in a Ruby file:
# I manually typed the pound at the start of this ...
0
votes
2
answers
640
views
Why does my vim colorscheme stay after I close vim?
I recently used vundle to install the solarized theme for vim on my Arch Linux machine. Whenever I open vim, the theme is applied, but it stays applied to my terminal window after I close it. I can ...
120
votes
4
answers
58k
views
How to get vim to open multiple files into tabs at once
Is it possible to get vim to open multiple files into tabs, similar to the way the args <path> command will open multiple files into buffers?
Doing something like :tabe ./* results in the error ...
6
votes
3
answers
5k
views
Vim - Move selection up/down with Ctrl+Shift+Arrow
I want to move a selection up/down with Ctrl+Shift+Arrow, similar like in other editors. What I currently have in my .vimrc is the following:
" from https://superuser.com/a/825561
:behave mswin
:set ...
8
votes
3
answers
3k
views
How do I define a vim function on a single line?
Since | is used to separate commands, I thought I could just do this:
:function! SomeFunc() | return 0 | endfunction
It works fine when I type it on separate lines (entering the first line causes it ...
1
vote
0
answers
94
views
Mac OS, How to run an executable that takes input in vim?
In competitive programming, we often have some small input we want to test our C++ program on. I already know of being able to remap some keys to make vim compile and run the executable.
However, I am ...
1
vote
2
answers
853
views
How do I move all of my dotfiles to a custom directory?
I'm a Mac user and I was wondering if there was a way to put all of my dotfiles to a .config folder to store all of them (something analogue to XDG Directories on Linux).
I was trying to set up a ....