Questions tagged [abbreviations]
Vim can handle abbreviations to replace some text by some other text. Question about creating these abbreviations and how to make them work.
68 questions
0
votes
0
answers
21
views
Is it normal for iabbrev to make vim slower to respond to key presses?
I am using neovim, from inside PowerShell on Windows 10.
I am working my way through "Learn Vimscript the Hard Way", and have set up the following iabbrev commands in my ~.vimrc file:
...
0
votes
0
answers
30
views
abbreviation stops expanding with "/"
The following problem with ab is seriously annoying me (seems to have started with vim 9.1):
In my .vimrc, I have ab FF ftp://test.com/www.
This will usually be expanded with e.g. / when I type the ...
1
vote
1
answer
24
views
Insert abbreviation and open completion
I sometimes add abbreviations for local files or projects.
For example having:
PREFIX_FOO
PREFIX_BAR
PREFIX_BAZ
Instead of typing PREFIX_ I map it to something, for example PP or P1, P2, ... etc.
:...
1
vote
1
answer
140
views
Lowercase user-commands?
After years of torture, my trusty rusty keyboard is finally waning its power—it now seems to believe that I'm jitter-clicking whenever I press q. Before getting a new one, I would like to ask if there ...
0
votes
1
answer
47
views
Paste from clipboard without triggering iabbr
I have the following in my .vimrc
iabbr Alice Bob
I have copied the text of Alice in Wonderland from Project Gutenberg using my system clipboard and would like to paste it into a new file in vim.
I ...
1
vote
1
answer
109
views
A problem with special character in Vim script
I'm trying to build a diacritic plugin which It's just a list of commands like
ia <leader>'e é " this one is source just fine
ia <leader>ae æ " This one causes error
But I'm ...
0
votes
1
answer
46
views
What other than mappings and abbreviations can change the text I'm typing?
The question
When editing TeX files (to do so, I use vimtex) if I've discovered that if I write lll in insert mode, I get \ell.
How do I find why this is happening?
My research
I thought "ok, I'...
0
votes
1
answer
101
views
vert command works but v doesn't
To open a buffer in a vertical split, you can use the word "vert".
For example :
:vert term #it opens a terminal in a vertical split
:vert sb1 #it opens the buffer 1 in a vertical split
...
1
vote
1
answer
90
views
Change " to `` or '' depending on whether it's typed after a space or non-space
The usecase is LaTeX, which I write using VimTeX.
To make double quoted words one would write ``words''.
However, I'm much more used, from many other contexts (both prose and code), to type " for ...
0
votes
1
answer
44
views
How to better define abbreviations by using variables?
I add the following lines in my .vimrc
let g:shell = "powershell"
cabbrev bter bo terminal g:shell
but that won't work (I got a CreateProcess failed error).
I have fixed with
exe "...
0
votes
1
answer
243
views
How to make an abbreviation that expands without pressing space
I am trying to replicate the behavior of beg abbreviation shown on the page https://castel.dev/post/lecture-notes-1/ with vimscript. That means I want to make it so that when I type "beg" in ...
0
votes
1
answer
83
views
List of Acronyms / Abbreviations for a paper
What is the best way in Vim to handle abbreviations for a paper? For example:
When working with Artificial Intelligence (AI) there must be .... and furthermore AI enables you to....
And later in the ...
1
vote
1
answer
81
views
How to prevent inoremap mapping from being "run" inside iabbrev? [duplicate]
I have the following abbreviation:
iabbrev .d. [[2021-12-02]]
I also have the following remap:
inoremap [[ [[]]<Left><Left>
The problem is, whenever I type .d. to get the date string, I ...
0
votes
1
answer
41
views
how to delete character which inserted automatically
I have the following mapping in my vimrc
inoremap < <><left>
but this statement conflicts with
iabbrev cout cout<<
and in insert mode I get cout<<>>
how to delete &...
0
votes
1
answer
397
views
Make 'cabbrev' work from command-line but not search prompt?
I am using NeoVim, and I automatically define an abbreviation for the string W every time the commandline mode starts.
However, it seems that commandline mode includes the search modes as well.
I do ...
2
votes
1
answer
155
views
Inserting abbreviation from file
First, I apologize if this is a trivial question.
I have the following file (main.ab) defining a Python snippet:
def main(args):
...
if __name__ == '__main__':
args = ...
main(args)
And ...
0
votes
1
answer
178
views
How to create an abbreviation that matches a regular expression
I'd like to create an abbreviation that will change the following (in a markdown file):
- list item 1
into this:
- list item 1
Whenever I type - f it should be expanded to - f (from 1 space to 3 ...
0
votes
1
answer
171
views
Cannot set `:p` as abbreviation of `:pu`
I am trying to set up an abbreviation for :pu as :p, so it is more consistent with :y and :d.
cnoreabbrev p pu
However this doesn;t work. It will just return cnoreabbrev p pu on the command message ...
3
votes
1
answer
606
views
iabbrev with <CR> and <Space>
I use vim to develop with Python and it works fine. However I want to improve the behavior for documenting my code. For instance I wrote this in vimrc :
:iabbrev """ """ &...
0
votes
1
answer
220
views
How to change cursor position when using iabbrev
When using iabbrev to abbreviate System.out.println (); as sysout, I want the cursor to be inside the parenthesis, not at the end of the sentence. Anyway to do this? Also, would it work for multi-line ...
0
votes
1
answer
57
views
Change text without interrupting abbreviations
I'd like to add a semicolon automatically in my current line. So I have this in my init.vim:
function Test()
if matchstr(getline(line('.')), ';') != ';' && strlen(getline(line('.'))) > ...
4
votes
0
answers
79
views
Can using too many abbreviations slow down vim?
Recently I started using the iabbr to the best of my abilities. While editing a file I may have sourced as many as 500 abbreviations. I have also noticed that my vim is slowing down recently.
The ...
2
votes
2
answers
702
views
How to create an abbreviation with space
I'm trying to create an abbreviation with the command ab:
if I type if ( under INSERT mode, I want some piece of code to be printed immediately.
Here is what I've tried:
ab if<Space>( if<...
2
votes
1
answer
62
views
Why does iabbrev end at second character, even after using 0 at the end of command chain?
This behaviour seems a bit strange (^ is the cursor):
inoreabbrev @@t <esc>0
what@@t
what
^
But:
inoreabbrev @@t <esc>0h
what@@t
what
^
Why using 0 is not enough to put the cursor ...
4
votes
2
answers
332
views
Abbreviations for local filtype buffers only
After typing tds I would like to see it replaced with the current time stamp in Markdown files, but eg. NOT while editing C source code.
The following mostly works (stripped for brevity) except that ...
0
votes
2
answers
214
views
vi/nvi (FreeBSD) How to make an abbreviation to a shell command?
I know how to make an abbreviation to a command in vim. For example to print the date, I have this in .vimrc:
iabbrev mydate <C-R>=strftime("%a %d/%m/%Y")
Now I'm running a VM with FreeBSD as ...
3
votes
2
answers
198
views
abbrev for multiwords
How to add abbrevs made of more than one word?
I've been trying:
iabbrev a aquilo àquilo
iabbrev a aquele àquele
iabbrev a aquela àquela
What I want to do is have the two words "a aquilo" expand to ...
1
vote
1
answer
138
views
Abbreviations: Count backslash as part of the word
I am usually writing LaTeX documents. I like to use
:iab iso isomorphism
so that if I write a sentence like This map is an iso., it will expand to This map is an isomorphism.. However, I also quite ...
0
votes
1
answer
106
views
How can I get vim to type continuously, rather than holding in place for keymappings?
For the purpose of this question, imagine that I have set
iab phil philosopher
In vim, as far as I know, the default display pattern when typing out the characters "phil" at the start of the word is ...
0
votes
1
answer
118
views
Prevent abbreviations from echoing on the command line
If I want to map a key to a certain command and I don't want the command to echo in the command line, I can do the following:
:nnoremap <silent> <leader>N <... command ...>
But can ...
0
votes
1
answer
257
views
iabbrev starting with semicolon
I want some abbreviations for common things typed in e-mails want to start them with a semicolon.
iabbrev ;ph 555123467
But this gives me an error:
E474: Invalid argument
I can have semicolon ...
2
votes
1
answer
555
views
Abbreviations add spaces when they shouldn't
I'm trying to create an abbreviations to insert a comment and to insert a TODO comment. I wrote them as following:
iab co /*__*/<Left><Left><Left>
This one produces the following (...
3
votes
1
answer
292
views
autocmd changes only applying to new files
I've been going through learn vim the hard way and am currently adding abbreviations via autocmd.
I've added the following to my .vimrc
augroup outputs
autocmd!
autocmd FileType php :...
4
votes
1
answer
750
views
How to put a new line character in an abbreviation?
I tried the following commands:
:abb sm Summary:\n
:abb sm Summary:\\n
but it didn't work, nothing escaped, I ended up with the long form instead of a break.
Is there a way to do that from ex mode? ...
2
votes
1
answer
164
views
vim-latex: sometimes abbreviations do not expand in tex buffers [duplicate]
I have installed vim-latex v1.10.0 on Fedora 28, using vim-plug:
Plug 'vim-latex/vim-latex'
I've defined an insert mode abbreviation:
:iab bd text
I can trigger bd to expand to "text" only with ...
3
votes
1
answer
169
views
Wrong abbreviation expansion
I have these abbreviations in my .vimrc:
iab seq sequent
iab seqs sequents
seqs expands to
sequents
i seq sequent
in a tex file (I have installed vim-latex).
In an empty buffer seqs expands ...
2
votes
1
answer
215
views
How to make abbrev ignore my custom keybindings?
For example, I've mapped inoremap ( (), and if I do iabbrev if if(then it will expand to if(then) instead of if()then (the inoremap is executed after the iabbrev). Is it possible to make iabbrev ...
1
vote
0
answers
119
views
Abbreviations do not work when space is conditionally remapped
I want to change the behavior of <Space> when the popup menu is open using this map
inoremap <expr> <Space> pumvisible() ? "\<Down>\<Enter>" : "\<Space>"
However, ...
3
votes
3
answers
287
views
Substitute an insert-mode input immediately
I would like to type begin! in insert mode and having it immediately replaced by:
begin [cursor here] end
I considered mappings:
:inoremap begin! begin end<Left><Left><Left><...
8
votes
1
answer
922
views
How to make command-line abbreviations that only trigger at begining of line
I have a custom save function, and bound it to :w by using an abbreviation:
cabbrev w call SaveBuffer()
This works, but I ran into issues when I wanted to reference window local variables because w: ...
0
votes
1
answer
66
views
Why won't Ctrl-C complete abbreviations when mapped to Esc?
I'm running vim -u NONE -U NONE, then doing :inoremap <c-c> <c-[> (or :inoremap ^C ^[, which I understand to be equivalent), and set an abbreviation, :abb dyca dynamic_cast.
The problem ...
3
votes
2
answers
451
views
Case-insensitive abbreviations
I use abbreviations extensively to make writing in languages other than English easier. For example, I have something like this set up for when I'm writing in Italian:
inoreabbrev perche' perché
...
0
votes
1
answer
161
views
Creating fillable "mini templates"
I am using somebody else's vim script that has a neat plugin that allows me type in something like sub<tab> and it will generate the following for me:
sub ___ {
___
}
The blank lines act ...
2
votes
1
answer
116
views
One abbreviation for various commands with different prefix?
To take a short cut in writing markdown files I need an abbreviation which can combine these abbreviations,
autocmd FileType * iabbrev pythoncode ```python```<left><left><left>&...
1
vote
2
answers
482
views
Abbreviation-likes containing spaces
Let's get directly to it.
I was working with some python code and realized I had written a bunch of elif blocks as else if after working too much in Javascript.
My natural thought was "cool, I can ...
3
votes
2
answers
165
views
Expand abbreviation when the following non-keyword character is mapped to something else
I've got the following mappings and abbreviations in my .vimrc
let mapleader = ","
inoremap <leader>( ()<ESC>i
iabbrev pirnt print
Now abbreviations won't expand if the following ...
1
vote
1
answer
2k
views
Remap <ENTER> so it makes new line and insert a datestamp
I'm making a program for taking statistics during sports, where I script the games. I'm would like to make a VIM shortcut/remap, so every time I press that it does exactly what the ENTER-key normally ...
1
vote
1
answer
152
views
How to get abbreviations to work inside nnoremap
I would like to have an abbreviation (xdate in this case) expanded when I use it in nnoremap. Is this possible? Here is what I've tried:
iab xdate <c-r>=strftime('%c')<cr>
nnoremap <...
4
votes
2
answers
1k
views
Shortcut / abbreviation to insert text block
I'm trying to do something fairly simple. I'm writing latex and I have all these blocks of code, that I'm trying to comment out (and disregard the words in the word count). So I have to write these ...
2
votes
1
answer
172
views
Something like iabbrev that works in the middle of words?
In LaTeX the \ldots command is used to make an ellipsis, so I wanted something like iabbrev ... \ldots that would work in the middle of words, so whatever... would become whatever\ldots.
Any ideas?