There is no built in command to start visual block mode in vim, but you can define one yourself:
command! Vb normal! <C-v>
Here is a breakdown of how it works:
command! Vb - This creates a command called "Vb". The ! after command means that vim will not throw an error if the command is already defined.
normal! <C-v> - This command tells vim ...
As far as I can find, there is no built-in command to start visual mode.
However, you can easily add these commands to Vim:
:command! Visual normal! v
:command! VisualLine normal! V
:command! VisualBlock execute "normal! \<C-v>"
You can change the names of these commands to whatever you want, but all user-defined commands must start with an ...
Let's get this confusion out of the way first:
Are these ex commands or Vimscript?
Vim scripts are made of ex commands. From :help script:
Your first experience with Vim scripts is the vimrc file. Vim reads it when
it starts up and executes the commands. You can set options to values you
prefer. And you can use any colon command in it (commands that ...
This should work:
command! Bro :enew | setl buftype=nofile | 0put =v:oldfiles
\| nnoremap <buffer> <CR> gf | 1
:enew doesn't support +cmd, unlike :vnew, so just split the :setl out to a new, chained, command.
I changed the mapping to use gf, which IMHO, is more native. The last command, 1, should move the cursor to the first line. Unlike ...
First clear an register: qaq
second, append all matching lines using the :g command:
Third, put all matches on a new page
:tabnew +$put\ A
If you want to be able to make changes on those filtered mached, have a look at my NrrwRgn Plugin. The advantage is, once you save the narrowed buffer, the changes will be taken back into the original ...
You can create a new empty buffer in a new tab and then populate it with the result of a grep search on the previous file:
:tabnew|0r!grep -n pattern #
In a mapping:
nnoremap <key> :tabnew\|0r!grep -n #<Left><Left>
Which works like this:
--- edit ---
Here is an alternative command that works with the current buffer instead of the ...
Ranges are not forwarded automatically, you need to use <line1> and <line2> for that:
command! -range Ex <line1>,<line2>!expand -t4
You should read the manuals of :help :command about -range and <line1>. Basically:
if Ex is called with a range, <line1> and <line2> expand to that range
otherwise, the default value ...
Commands (custom as well as built-in) are used in mappings, scripts, plugins. If you could override them, it would be very easy to break functionality.
There is a mechanism for customization that doesn't suffer from this (command-line mode abbreviations); unfortunately, they don't differentiate (between commands and arguments, or commands and searches),...
You probably want to read :h user-commands and put the following in your vimrc:
command! -nargs=1 -complete=file E tabnew <args>
You can't override :e but you can create the command :E which will take one argument (-nargs=1), complete this argument as tabnew does (-complete=file) and executes tabnew with the argument it took.
However as @Hotschke ...
I don't believe it's possible to redefine :Glog without losing access to the script-local function.
However, bearing in mind your muscle memory is for glog, not Glog, I propose another approach:
cnoreabbrev <expr> glog (getcmdtype() == ':' && getcmdpos() == 5) ? 'Gitv' : 'glog'
This abbreviation will convert your :glog commands into :Gitv ...
If you are using the :%s command, you are already using some very simple VimScript. So much for not learning it :)
If you want to create your custom command, you can use e.g.
com! -nargs=1 Replace :%s/<args>/gc
This defines a new command :Replace and you can use :Replace foo/bar to have all foo be replaced by bar across the complete document.
See this answer on stackoverflow.
The example given is:
function! PrintGivenRange() range
echo "firstline ".a:firstline." lastline ".a:lastline
" Do some more things
command! -range PassRange <line1>,<line2>call PrintGivenRange()
Thus you might want to create a function which would use the range and do the tmux call ...
Your problem is that :command does not (by default) accept the use of bars, as explaind in :h :bar. You may circumvent this by using the -bar option, see :h :command-bar:
command! -bar Tags execute '!GTAGSFORCECPP=1 gtags'
\ | cscope kill -1
\ | cscope add GTAGS
You can also wrap the functionality in a function, like this:
command! Tags :call s:...
Your mapping doesn't work because you are in a rare case where you want to use nmap instead of nnoremap: You want to use in a mapping an already defined mapping. Using nnoremap you said to Vim "use the default behavior of ysiW"" instead of "use the behavior defined by a plugin"
If I understand your mapping correctly you want to be able to transform
you can also adapt this one liner
command -range TmuxSession execute "!tmux.session " . @*
or if you do need multiline visual selection change @* to substitute(@*,"\n"," ","g")
The @* register stores current selection (for linux, on windows there could be different naming convention).
The -range is only to avoid an error if you want to execute this ...
Like everyone else, I recommend pretty strongly against doing this, but if you're dead set on the idea (and for future readers who might be doing something slightly different) you could use something like:
:cabbrev <expr> e getcmdline() == 'e' && getcmdtype() == ':' ? 'tabnew' : 'e'
This will replace :e with :tabnew as soon as you type the ...