Better "bro ol"
Inspired by a nice solution on a Stack Overflow, the following was put in my vimrc:command! Bro :vnew +setl\ buftype=nofile | 0put =v:oldfiles \| nnoremap <buffer> <CR> :e...
View ArticleHow to create user command without a capital letter as first letter?
I know I can set user-defined commands using the :command Foo bar syntax, but I want a way to set a command without using capitals.For example, to save all open buffers, the command is :wa, but that's...
View ArticleWhy does the escape sequence insert the current line number in my user command?
I've added the following to my .vimrc in order to test how <count> works in a user defined command because I was noticing odd behaviour::command! -count=1 CountTest :exe "echo " . <count> ....
View ArticleExtract JavaScript variable (feature example): how to improve it?
I am a Vim newbie with one week experience and I'm already enjoying it.I've successfully written an (ugly) command+function+mapping with which I can extract some code to a new variable in JavaScript....
View ArticleMapping using tpope/vim-surround only works with command
I have this mapping to surround a Word with jQuery id selector $("#...") and it works fine using a command:command! JqId normal viwo^[i#^[ysiW"ysiW)i$^[Ennoremap <Leader>jqid :JqId<CR>But I...
View ArticleUsing arguments in a .vimrc command
I've discovered that I can edit the .vimrc file to create custom commands and would like to create simpler search and replace alternative commands, but have no idea how to edit %s/foo/bar/gc so that it...
View ArticleHow to edit a file in a new tab?
I want to map :e file.txt to :tabnew file.txt, or the equivalent setting for editing file in a new tab. What do I need to put into my vimrc?
View ArticleIs it possible to non-recursively remap a command?
So Fugitive defines :Glog. This is, apparently, aliased to a call to the script-local s:Log() function (according to :command Glog.)My muscle-memory has been using glog at the command-line, for years,...
View ArticleWhat is the purpose of user `command` in Vi/Vim?
What is the purpose of user command in Vi/Vim? I noticed that a lot of commands are usually used to call functions like this:command! TrimWhitespace call TrimWhitespace()From my observation, command...
View ArticleHow to use variables in a user defined command? [duplicate]
I have this user defined command:command! PS silent! w | PlugSnapshot! ~/.vim/plugins/plugins.lockHow could I change it to take the filepath from a variable, something like this:let PathToPluginsFolder...
View ArticleHow do I remap the :make command to run a docker container?
I use a custom docker container to build my project so my "make" command is actually docker run --rm -v $(pwd):/src container make $arg.I'd like to be able to type :make $arg in command mode and have...
View ArticlePassing visual range to a :command as its argument
I have a command:command! -nargs=1 TmuxSession !tmux.session "<args>"and I want to run it in visual mode so that selected text will be passed as argument.By selected text I mean selected in...
View ArticleChaining user-defined commands [duplicate]
Assuming I have defined 2 commands in .vimrcMultipleEmptyLinesToOneRemoveExcessiveSpacesI can run them in command-line mode::exec "'<,'>MultipleEmptyLinesToOne" | exec...
View ArticleHow can I execute commands or move to other tabs without first closing the...
I've created a new terminal by executing :tabnew +term.How can I execute other Vim commands or move to another tab without first closing the terminal (:term)?Currently, all input is directed to terminal.
View ArticleHow to create user command to delete current file and saveas to new file?
I use :saveas to move a file while maintaining its undo history. Most of the time I immediately delete the old file. So if I'm editing foo.txt I'll issue:saveas bar.txt:!rm foo.txtI wanted to make this...
View ArticleIntercepting & modifying commands
Is it possible to intercept incoming user commands? For example, if the user executes :echo 'hello', then I would like to compare the string and the command, and change it to execute :echoerr 'hello'...
View ArticleHow do I call a function from a user command? (Getting a "trailing character"...
So I was trying to setup a custom command to change tab width on the fly.function! SetTab(width) set tabstop=a:widthendfunction:command Tab -nargs=1 call SetTab(<args>)The idea is to when I type...
View ArticleHow to make an user-defined command that works in normal and visual mode?
GoalI would like to create a command that can automatically put an x inside a [].This command should work in both normal mode and visual mode.normal modeIf it is in normal mode, and the cursor is on...
View ArticleHow to delete all user-defined commands starting with XYZ?
How can I delete all user-defined commands where names share a common prefix (e.g. XYZSomeCmd, XYZAnotherCmd, ...)?Found myself with a lot of dead commands while writing a plugin and changing prefix...
View ArticleCustom Arguments to User Command
I am trying to create a command that runs a function, however, I can seem to get custom arguments that are autocompleted when pressing Tab. How would it be possible to set these arguments?The current...
View Article
More Pages to Explore .....