Skip to main content

Questions tagged [command-line]

Questions on ex- or colon-commands. For questions about command-line options used to launch the editor, use the [invocation] tag.

Filter by
Sorted by
Tagged with
0 votes
1 answer
79 views

Stop flushing the last command when hitting enter

Suppose I wrote this command: command! -nargs=1 E echo ' -> <args>' and when user feeds an argument, :E abc I intend to see the following effect as they hit Enter: :E abc -> abc Of ...
0 votes
1 answer
30 views

vimscript function suggest in command-line mode?

At home I have Ubuntu LTS and my gVim command-line mode displays a horizontal list of vimscript functions as you type them after you type :call. At work we run Windows and gVim, but the same ...
0 votes
1 answer
47 views

Printing (file) information at the bottom line

I'd like to print some file information on vim's bottom line upon pressing a keyboard shortcut, sort of like Ctrl+G but with different info (modification timestamp). How can I output there? My current ...
2 votes
2 answers
136 views

creating a ":KeepCursor" command

I'd like to make a command that works like this: :KeepCursor {cmd} will the given execute ex command string, then restore the cursor's position. A primary example is: :KeepCursor normal! * which ...
1 vote
1 answer
81 views

Are there any performance difference between :edit and :buffer on existing unchanged buffer?

I used to believe that :buffer file is faster than :edit file if file is an existing unchanged buffer. I even created a tiny function for this: function! myvim#open(file) abort let nr = bufnr(a:...
1 vote
1 answer
169 views

Print Command Without Hitting Enter

Suppose I map a key to enter a command in the command buffer, but without hitting enter: function! BuildSystemTask() if inProject() "generic function that checks if I am in a buildable project ...
4 votes
1 answer
768 views

Open command-line-mode from VimScript function

How to reproduce this mapping: nnoremap <Leader>a :DoSomething <C-r>=do_something_arguments()<CR> ..in a function? The desired effect is to open command-line mode with some text ...
2 votes
1 answer
1k views

'@' in file names and 'gf' (go to file)

Vim/Neovim (this is an issue in both as far as I can tell) does not seem to like files with '@' in the name, even though I have isfname is set to the default, which is @,48-57,/,.,-,_,+,,,#,$,%,~,=, ...
2 votes
2 answers
168 views

In command-line mode make delete not act like backspace

In command-line mode there is no delete from cursor to the end of line (like CTRL-k in bash). So to delete a long line of trailing text, I press and hold delete, which works fine until it runs out of ...
1 vote
1 answer
47 views

What does + preceding command do in vim

What does + preceding command do in vim, for example from this command from this website: botright 10new +setlocal\ buftype=nofile\ bufhidden=wipe\ \ nobuflisted\ nonumber\ ...
2 votes
1 answer
1k views

execute + colon character doesn't work

I want to :retab selection in my vimscript function. When I write execute "normal! :'<,'>retab" nothing happens. If I write: let cmd = "normal! :'<,'>retab" echom cmd The output is ...
0 votes
1 answer
385 views

How can I set a variable for a single Vim Ex command only?

I often set or modify a shell variable in Bash for the scope of a single command only: $ FOO=BAR <command> Is it possible to set or modify a variable in Vim for the scope of a single Ex ...
11 votes
1 answer
440 views

Why does `<Bar>` behave like `|` in the `:command` command in Vim?

Here is the list of experiments I performed that shows that <Bar> is treated as literal <Bar> in some commands but it is treated as | in the :command command. I am trying to understand why ...
2 votes
1 answer
960 views

How to display a list of all folds?

How can I show a list of all folds? e.g., maybe a list something like: 1-3 12-18 13-16 where <start-line>-<end-line> are the starting and ending lines of the fold. Is there a command-line ...
0 votes
1 answer
489 views

Disable command but allow to write in command mode

I have fzf.vim installed, and therefore I have a :W command. I prefer working with buffers, so I save a lot with :w. However, accidentally using a capital W invokes :W which annoys me. I tried ...
0 votes
1 answer
836 views

Mouse navigation not working in Vim

I started using Vim today and I found out that we could use the mouse pointer to go to a line in vim using set mouse=a But unfortunately, it is not working. Here is the config file: https://pastebin....
2 votes
3 answers
663 views

How can I execute Lua code from a buffer?

I realized that for a very basic lua debugging the most simple way is to write directly the code in the command line (no plugin, no DAP). For example: :lua print(vim.inspect(vim.api.nvim_list_wins())) ...
2 votes
1 answer
369 views

How to pass custom arguments to the shell invoked by :terminal?

I would like to specify the startup command to run on the :terminal shell. E.g. bash -c ls. The shell can be specified with set shell=bash, but how to specify the arguments? In another use case, I ...
2 votes
1 answer
420 views

Passing arguments function with --argument or -a format

Is it possible to pass arguments to Vimscript functions with the --argument or -a format, similar to arguments in the command line? I am writing a command that submits a job in a remote machine. I ...
0 votes
1 answer
81 views

How do I send the output of an :r! command to another Vim command?

I would like to edit some text before dumping it into the Vim buffer. I retrieve the content of a webpage with :r! w3m -dump someurl.com. I would like to delete everything in the returned text from ...
1 vote
1 answer
34 views

Apply next non-blankline function as one part of multi-part user-command

Why do I seem to get different results when I apply this function from the Vim command line than when I apply it as part of a user-command? " advance to next non-blank line only if current line ...
7 votes
1 answer
5k views

How do I quit vi/Vim/Neovim?

I opened vi myfile.txt (or vim myfile.txt, or nvim myfile.txt) to use vi/Vim/Neovim to edit a file. Now that it is open, how do I quit? If I open vim with no file, the intro screen says :type :q<...
3 votes
1 answer
447 views

Plugin nnoremap insert <CR> instead of executing command

I am writing a vim plugin that at one point define a buffer only mapping : function! s:DoStuff() tabnew " ... nnoremap <buffer> q :tabclose<CR> endfunction call s:DoStuff() ...
1 vote
1 answer
145 views

Automate find and replace

When having selected something in visual mode where I want to perform a find-and-replace I always have to run :'<,'>s/foo/bar/g manually. Is there some way so that I can bind it to some key ...
1 vote
4 answers
66 views

Programatically enter Command line window

I have bind q to :qa that hides q:. Is there a command to enter the Command Line Window that is not q:? How to access the Command Line Window without typing: q:?
1 vote
1 answer
56 views

How to show outputs of a ":!cmd" command on a new screen, rather than at the bottom of my screen?

Whenever I type a shell command, like: :!ls Neovim will display it at the bottom of my screen. I'd like it to, instead, clear the whole window, and display it at the top. Is that possible?
0 votes
1 answer
146 views

How to delete all lines in a command script without provoking error?

I'm trying to write a Vim command script (a file containing Ex commands) that removes all existing lines in a file (and then read in some new text, and do some further editing operations). I use the ...
-1 votes
1 answer
154 views

Remove right text (line numbers , ALL) in command line

I am using neovim and i want to remove the indicated text (0,0-1 ALL).
0 votes
2 answers
2k views

Vim command to open zathura immediately after a latex compile?

I have the following line in my nvim configuration file: map <leader>c :w! \| !compiler <c-r>%<CR>\| !zathura $(echo %:r".pdf") && disown<CR><CR> The ...
0 votes
1 answer
108 views

How to open the last modified file at startup?

As every user in this community understands, launching Vim using the command line without using any arguments or flags will edit a blank buffer with the :intro screen. Some distributions and utilities ...
-2 votes
1 answer
66 views

MacVim: how to prevent :[range]!say to remove text? [duplicate]

I am writing some prose and I find very useful to hear what I wrote from an external voice. I found the command say which I guess is only available on MacOsX (perhaps other OS have some equivalent). ...
2 votes
1 answer
48 views

Is it posible to disable replacing "%" to the current file in commands?

I'm using a command to transform an URL to another form in my text_file: :r! my_command 'https://example.fqdn.com/path%20with%20loads%20of%20spaces' The problem is that every % char is converted into ...
-1 votes
1 answer
36 views

command-line: filter history based on the current command line with CTRL-P

Say that in my command-line history I have the following: :cd ~/Document :e myfile.txt :cd /opt/bin Then, if I type :cd and then I hit <up> the command become :cd /opt/bin and if I hit <up&...
1 vote
1 answer
167 views

Vim command-line mode encoding error when using global search in autocmd

Update Found the issue due to souce the menu this cause encoding=utf-8 and fileencoding=cp936 in _vimrc but in txt files it shows encoding=utf-8 fileencoding=utf-8 The way to fix is reset fenc=utf-8 ...
2 votes
2 answers
93 views

Reading commands from stderr

In the Vim man page, I came across the following option: - The file to edit is read from stdin. Commands are read from stderr, which should be a tty. I think I'm misunderstanding this, as I can't ...
8 votes
2 answers
465 views

Opening multiple files on specific line numbers in vim

I would find it useful to open several files at the same time on specific lines. I know I can open a single file on a specific line with: vi +123 ~/.zshrc And I can open multiple files with: vi ~/....
0 votes
1 answer
117 views

Vim commandline history and viminfo

I can't understand why when I open (Win10) gvim91 and press :<up> I don't see my most recent command. I'm sure it used to be this way in previous versions of vim (I updated recently). What I see ...
1 vote
2 answers
204 views

How do I stop Vim from pasting my code as a comment?

Suppose I copy some code from a place and try to paste it into Vim, it comes as a comment. Is there any way to fix this? Example: --Return the smaller thing p ::forall a. (Eq a)=> [a]-> a->...
0 votes
0 answers
31 views

How to get/print all max-nested non-empty subdirs starting from some path(dir)?

How to get/print all max-nested non-empty subdirs starting from path(dir)? I found a random option to do this on Linux (bash): find ~/.config/nvim -type f | sed 's%/[^/]*$%%' | sort -u But I'm ...
3 votes
1 answer
71 views

How can I rename the current buffer to the current time?

I have tried :file strftime("%H%M") But this sets it to literally "strftime("%H%M")". My motivation for this is that I have a mapping for :term cmake and I end up with a ...
2 votes
2 answers
121 views

Can't stop the global command using subcommand :substitute (:s) with the check flag (c)

I'm trying to use the global command :g with :substitute to find and replace some string and also with check. So the command like: g/\d/s/.*//gc but the check behavior is not same as in :s I can't ...
1 vote
0 answers
85 views

How can I handle whitespace of the path with nvim_buf_get_name?

I am using Neovim and I use this code to get the full path of the current file. local currnetPath=vim.api.nvim_buf_get_name(0) I want to use this variable for opening the current HTML file, so I need ...
5 votes
2 answers
203 views

Autocomplete ^X^F mode in another directory

I notice when I launch Vim, the ^X^F completion works in the current directory I launch Vim in, not where the current file is. For example, if I use vim /path/to/foo/file.txt instead of vim file.txt, ...
34 votes
8 answers
31k views

How to go to previous open buffer from Vim command line?

I am trying to write a Vim function which should make the window go to the previous open buffer. How can I do it from the command line? My first idea was to find out some Ctrl-O command line ...
1 vote
1 answer
120 views

How can I echo a variable and redirect it to a file, register or the clipboard?

I'm using a colour scheme which makes some text unreadable in the vim terminal. Therefore I want to alter g:terminal_ansi_colors. :echo g:terminal_ansi_colors This shows me the value of the variable, ...
2 votes
1 answer
109 views

Vim command-line just say 'saved' upon save

In Vim, at the the bottom. There is statusline. And below it there is, I think, the command line. When I press save, this command line, displays something like: "index" 160 lines, 2097 ...
1 vote
1 answer
126 views

Put the mutiple search or replace results into different split window

Dsecription I am using :g/regex to do global search and it always list --More-- So I need to click Enter or Space to see the full results, it takes too much time. I found one way to achieve my goal ...
1 vote
1 answer
58 views

How to save the files when global replace completed in one command line

I have so many huge size of files and always need to do search and replacement so I map the command as nnoremap aa :let i=1 \| g/regexp/ s/^/\=printf("%1d. ",i)/g \|let i =i+1\|:w! 1.txt ...
11 votes
6 answers
32k views

How do I copy and paste between two Vim instances - shared clipboard?

I use gnu screen and I run vim file1.txt and vim file2.txt in two windows. How can I copy part of the text from file1.txt and paste it to file2.txt without using temporary files or opening two files ...
4 votes
1 answer
126 views

How to get autocomplete for :set?

E.g. I am trying to change foldmethod to syntax: :set foldmethod=s^I^I When I press tab after typing s, I get ^I instead of auto-completing to syntax. Only possible options are manual,indent,expr,...

1
2 3 4 5
10