Questions tagged [vimrc]

Vim reads initialization commands from a file called vimrc on startup. This can be used to set settings, define functions, execute autocommands, and more.

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

Why cant i use `"+` in vim?

Whenever i typed previously in vim this command "+yy it yanked a line to system clipboard. However i reinstalled the OS again and when i try to do same now "+yy the keyword disappears after ...
1
vote
0answers
32 views

:terminal colorscheme inside Vim is different from either Vim or Host Terminal

I have a gruvbox theme applied to Vim inside vimrc. The problem is that when I run the :terminal command inside Vim the colorscheme is different from either the Vim theme or the Terminal theme. I have ...
2
votes
2answers
31 views

Execute a vim command after entering vim

Is it possible to send a command to vim from the command-line? For example, to open the last file something like: $ vim -e "`0" # execute `0 after opening vim Or, if I need to run a ...
0
votes
0answers
14 views

Gruvbox theme for Airline resets every time Vim closes

I have installed gruvbox using vim-plug, then I installed Airline and set the theme following the recommendations. But every time I close Vim and open it, the theme for Airline is reset to default and ...
0
votes
1answer
37 views

How to paste/merge 2 blocks of text in vim

I search a way to paste/merge 2 block of text block A apple pear banana block B tomato beans potato to this apple tomato pear beans banana potato I'm looking for an easy way to do this using macros....
0
votes
1answer
16 views

Suggested to use recursive or non-recursive mappings to normalize mapping

What approach would be preferred to allow a cmd-s to trigger a save, regardless of mode: " Allow i,c to call normal mode noremap <leader>S :silent call SaveFile()<CR>asdfidfo ...
0
votes
2answers
19 views

How to resource a file from within a function

I have a shortcut -- ⌘s to save a file. If it's not a vim file it will just run a :w, and if it hasn't been saved to a file yet it will ask the user for a filepath or name. However, if it's a vim file,...
0
votes
1answer
13 views

Filetype events in autocmd

To run an autocommand on a python file I can do: :autocmd FileType python nnoremap ... However, what 'event' does this run on? Is the event FileType or is Filetype python basically doing a ...
0
votes
0answers
10 views

Paste into search instead to buffer with vim-fuzzyseach?

I’m using this plugin and find it useful with its regrex search and as it’s not updated recently, I find that when I map it to / to replace default function search of vim and then try to paste text ...
0
votes
1answer
9 views

How to ignore helpfiles in a *.txt autocmd

In the following autocmd: " Default filetype, color if unrecognized (like a text file to write notes) augroup DefaultFiletype autocmd! autocmd BufRead, BufNewFile *.txt set ft=markdown ...
0
votes
1answer
29 views

Two types of method call

What is the difference between the following two ways of calling a function/method in vimscript? " This seems to always work call add (events, e) " This seems to occasionally work events-&...
0
votes
1answer
12 views

truthiness / boolean comparison in vim

I'm having a hard time understanding why the following equivalence produces two different results: echom a:events == '*' echom string(a:events) == '*' The first one returns 1 while the second one ...
0
votes
0answers
17 views

Understanding some autocmd events

When logging autocommand events, I came across a few ones that seem a bit strange: User -- seems to be logged very frequently, though the vim help really only mentions "it's not a real event and ...
1
vote
1answer
27 views

How to grab event type

I have the following script to log various events: augroup EventLogger autocmd! autocmd! BufWrite,BufEnter,User * call LogOutput(" getEventType() ") augroup END How would I ...
1
vote
1answer
9 views

Suppress output of expression register?

Is it possible to suppress the output of a register? For example, I am using getchar() to 'consume' a character, but I don't need it to return anything. I suppose I could add in a hackish ternary ...
3
votes
1answer
30 views

Understanding EatChar function

In using an iabbrev, vim help gives the following example of how it can be used to ignore the character after typing in the keyword: Towards the bottom of Abbreviations: You can even do more ...
0
votes
1answer
26 views

How to get autocmd/iabbrev command to update?

I have the following command which defines an iabbrev: if !snips_installed augroup VimLogger autocmd! autocmd Filetype vim iabbrev <buffer> log hello!! augroup END endif ...
0
votes
0answers
13 views

How to view when events fire? [duplicate]

Is there a verbose mode that shows when each of the various events fire? For example, I'm looking for something where I can use vim in the normal course of operations and see which events are being ...
0
votes
1answer
30 views

How to get last *executed* command

To get the most recent command I can do: :<ctrl-p> Or: :<up> However, this will also show commands that might have been typed in, but weren't run, for example, I may recently typed in: :...
0
votes
1answer
10 views

Writing an autocomplete function

I am trying to use the omnicomplete. It is quite simple to use in insert mode, but I'm having a hard time using it from a function. Here is what I have so far: " Cmd-. to autocomplete tags, ...
0
votes
0answers
13 views

Understanding a filetype regex

How does the following regex (or is it a regex?) work: au BufWinEnter,BufRead ?* loadview I believe that ?* makes sure that the filepath has at least one character, but why isn't this then just .. ...
1
vote
1answer
32 views

Scoping an autocommand

Is the following a properly scoped autocommand to work on HTML files? " Option-space as &nbsp; in html augroup HTML autocmd! autocmd FileType html,htmldjango inoremap <buffer> &...
0
votes
1answer
15 views

Vim regex match between asterisks

What would be the following vim regex to get the word term in: hello my*term*here My thought was: *\zs[^*]\ze* But it seems like there are some things I need to escape here that aren't working. The ...
1
vote
1answer
20 views

How to 'reset' an option to default

I have set foldtext like this: set foldtext=NeatFoldText() Is there a way to: view what the default value is for a option? reset option to its default value (without having to exit/re-enter vim)
1
vote
0answers
12 views

Vim folding very slow on large file

I have a large python file (~ 4k loc) and even if I do one manual fold in the code, it seems like all actions take about 3x longer to do, regardless of whether it's in or out of the fold, close or far ...
1
vote
1answer
25 views

Formatting of folds

Is it possible to 'fold at the proper indentation' ? For example, the point in the below is to see conditional flow: However, with how the above is formatted, it's almost impossible to see visually ...
1
vote
2answers
44 views

Vi: how to use bash from the vi command line?

Suppose I have mapped the following function: noremap <C-F12> :! bash -c "\ git rev-parse --show-toplevel \ | xargs -I {} \ ctags -R --sort=yes --c++-kinds=+p --fields=+iaS --extra=+q {}...
1
vote
0answers
20 views

Make nerdtree use the same nerdtree buffer when entering many directories

In nerdtree, if I enter many directories and then open the file I want, my screen would look like this: | nerdTree window | Tab1:directory1 | Tab2:directory2 | Tab3: file1 | Tab1 and Tab2 are not ...
0
votes
1answer
33 views

Organize plugins and .vimrc settings for different filetypes using ftplugins?

I'm new to vim (8.2) and have been learning how to set it up on my computer (Ubuntu 18) for the past few days. I'd like to configure VIM so that when I open code in different programming languages, ...
0
votes
0answers
26 views

How to 'save' manual folds in vim [duplicate]

Often I will have very long static variables at the top of a file, for example a mapping COUNTRY_TO_ISO. I usually fold those mappings with foldemethod=manual. For example: However, when I save the ...
-1
votes
1answer
33 views

Understanding various ctrl-r variants in vim

I will use ctrl-r quite frequently in insert mode to insert contents of a register, for example, ", %, or any of the [a-z] registers. I've also come across the following in the help: tag ...
0
votes
1answer
17 views

Trouble with nerdcomment mapping (mapping leader, which maps to itself)

I tried doing the following mapping in NERDCommenter: nnoremap <leader>/ <leader>c<space> However this was not consistently working. I verified the ttimeout was a high value, and ...
0
votes
0answers
21 views

Where is vim case-sensitive

Is there a good guide to in which places vim is case-sensitive, which places it isn't, and which places it depends? For example, three examples would be: Functions, variables seem to be case-...
0
votes
1answer
17 views

Moving and deleting one word at a time using Ctrl + Arrow keys or Ctrl + Del

I want to know if it's possible to delete a whole word or move around one word at a time when in INSERT mode, like in "regular" applications when pressing Ctrl and using the arrow keys jump ...
0
votes
0answers
14 views

Nerdcommenter function to check if line has comment

Without executing an actual editing command, is it possible in NERDCommenter to check to see if a line has a comment or not? I'm sure this is used internally, but I'm thinking about hopefully using ...
0
votes
3answers
34 views

How to determine where formatoptions being overwritten

I have the following in my vimrc file: :set formatoptions-=cro However, when I load the vimrc from scratch (i.e., open a new terminal session and start vim with it), it seems to be overwritten ...
0
votes
0answers
11 views

EasyMotion — one OR two chars

It seems that EasyMotion suggestions using two different mapping to find a one- or two-char match. For example, I've mapped a two-char find and it prompts me with: Search for 2 characters: However, ...
1
vote
2answers
34 views

Disable search highlighting after running a substitute command

Is it possible to enable hlsearch when running a search (/) but not on : commands? For example, sometimes when doing a replace (on a very narrow range of text) it get distracting when I have a bunch ...
-1
votes
0answers
14 views

System clipboard — * vs +

I was reading an article on Registers, and it lists + as the system register: "% has the current file path, starting from the directory where vim was first opened. What I usually use it for is ...
0
votes
1answer
26 views

List of all escape characters as they are displayed in vim

Is there a listing of the various escape codes and how they are represented in vim (and outside I suppose to)? For example: ^M -- newline ^@ -- NIL etc. It seems I always have trouble googling ...
1
vote
1answer
20 views

How to receive a python variable from vim [duplicate]

How would I do the following in vim using pyx ? let abc = 123 pythonx print (abc) # >>> NameError: name 'abc' is not defined From above, it looks like python doesn't have access to the vim ...
1
vote
1answer
28 views

python vs pyx in vim

I'm a bit confused as to what the difference is between python and pyx in vim, other than one seems to work and the other does not. For example: pyx print ("OK") This works, however, this ...
1
vote
2answers
35 views

Difference between % and g command

What is the difference between doing :% [...] and :g [...]. Does g require a regex to filter out what lines to apply to, or does it apply to all lines if no regex is given? For example: To insert a &...
4
votes
2answers
57 views

Re-source a file whenever I save a vim file

I would like to set an autocommand that automatically resources the file whenever I save it, as now I am doing something like: :w | so % Whenever I save something. What would be the correct 'event' ...
0
votes
0answers
28 views

Vim syntax highlighting becomes crazy

Some overview and history. Environment: OS: Windows 8.1 Emulator: cygwin (mintty) Terminal: xterm-256 Vim: v8.0 (Cygwin edition) Vim setup: Plugin manager: VimPlug Enabled plugins: Plug 'scrooloose/...
1
vote
1answer
21 views

When to use set vs let vs & to view variable value

I get a bit confused as to when we access a variable value like this: :echom &textwidth " 120 And when it's done like this: :let a " a #4 And when it's done like ...
1
vote
2answers
35 views

Why does cursor position on >> and << go to start of line?

Whenever I press << or >> in insert or normal mode, I lose the cursor position, as it always goes back to the start of the line. Is there a setting to fix this? Here is where I am right ...
0
votes
1answer
29 views

Vim how to print the mode I am in

Let's say I have a visual selection: How would I print the mode from the commandline? I've tried doing: :'<,'><C-U>echom mode() And a few variations of that, but haven't been able to ...
2
votes
1answer
22 views

Mappings for three different visual modes

Is it possible so that each of the different visual modes have different mappings? For example: visual-block-noremap A BB visual-line-noremap A CC visual-normal-noremap A DD ...
0
votes
0answers
14 views

Evaluate function: scoping of variables

I've tried initializing fzf in vim to only take into account a few directories, depending on which machine it is. This is in the vimrc: I've used global variables and then 'unlet' them at the bottom. ...

1
2 3 4 5
25