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
1
vote
1answer
14 views

Vimrc syntax move up and down a certain line continously

So I am new to Vim and I am trying to understand the language of vimrc. I have this in my vimrc: map <F8> <C-E>: sleep 100m<CR>j<F8> This would automatically move the cursor ...
1
vote
1answer
20 views

Convert very long execution mapping into a proper function

I commonly will have a long list of ids that I will need to convert into a tuple for a SQL query or perhaps to create a array in python/javascript. Here is the command I've written to format a list of ...
0
votes
0answers
26 views

Go back to previous cursor position (column) on same line

When I execute a function in vim, it puts my cursor back on the line at column 1. Is there a way to get back to where my cursor previously was on that line, i.e., the exact column number? I thought ...
1
vote
1answer
25 views

Redirecting output in sub-functions

I am trying to write a wrapper that will execute the function that the cursor is over and send its output to a log file. Here is what I have so far: nnoremap <expr> GG ExecuteCurrentFunction() ...
0
votes
2answers
31 views

Redirect echom output in a function to a log file

I would like to debug functions a bit more easily. Instead of running them and having to do: :10 messages To actually just have a vim.log file opened and tail -f'ed so I can see the output while it'...
0
votes
0answers
50 views

Redirect output of vim command into the vim buffer

To read a file into the vim buffer I can do something like: :r myfile.txt Or to grab a command's output: :r !ls Is there a way to run a vim command and get the output to where my cursor is? ...
0
votes
0answers
21 views

Using hlsearch and noh

I am using the following two items in my mapping: set hlsearch nnoremap <esc><esc> :noh<return> When I search I normally like to see highlighting, and then once I get to 'where I ...
0
votes
0answers
9 views

Converting if to ternary not working after first execution

I have two functions, one using an if statement and one using (or trying to use) a ternary expression: nnoremap <expr> Z Toggle1() func Toggle1 () if g:colors_name == "OceanicNext" ...
1
vote
1answer
239 views

Usage of printf command in vim

I see from :h printf that there's a print function in vim: printf({fmt}, {expr1} ...) printf() Return a String with {fmt}, where "%" items are replaced by ...
0
votes
0answers
7 views

String concatenation/formatting similar to c [duplicate]

To combine a string I am doing something like: echom '111 full_string: ' . full_string Is there a way to "in-line" it, for example, something like: echom '111 full_string: %s' % full_string
0
votes
1answer
48 views

How to 'enter' or add a carriage return in an <expr> mapping

In the following nnoremap: nnoremap <expr> <leader>3 ToggleColors() func ToggleColors() if g:colors_name == "OceanicNext" return ":colorscheme TextMate" else ...
0
votes
1answer
23 views

Writing a vim function with string printing and concatenation

I am trying to write my (first) function which is (eventually to be) a toggle on my colorscheme. What I have now is as follows: nnoremap <expr> <leader>3 ToggleColors() func ToggleColors()...
0
votes
1answer
154 views

Variable vs global variable

In h: internal-variables it mentions the "global" variable which is prefixed by g:. What would be the difference between: let g:var = "xyz" And: let var = "xyz" Does the absence of a prefix mean g:...
1
vote
1answer
35 views

Let vs set syntax in vimrc

I can do the following to set the synmtaxcol: :set synmaxcol=4 Or: :let &synmaxcol=4 However, when doing the same with colorscheme, only this works: colorscheme TextMate And not: let &...
-2
votes
1answer
47 views

autocmd vs augroup example [duplicate]

Is there any difference between the following two commands: autocmd FileType html,htmldjango inoremap <buffer> <leader>1 &nbsp; And converted to an autocmd: augroup filetype_html ...
0
votes
1answer
28 views

Remember how variable/param assignment is done

It seems quite tedious for me to remember how various settings are assigned, and so I find myself looking at :h or google or posting here to figure out how each setting is assigned (or just doing ...
0
votes
1answer
24 views

Order of when a variable is set or overriden

In some trial-and-error testing using the following two statements: iabbrev <buffer> return NONONON autocmd FileType python :iabbrev <buffer> return YESYESYES It looks like regardless of ...
0
votes
1answer
32 views

Restricting filetype mappings

I have written the following mapping in my vimrc: autocmd FileType python :iabbrev <buffer> for for item in:<left> After I source the python file it works. However, now whenever I ...
0
votes
0answers
22 views

How to re-source a file based on filetype [duplicate]

I am trying to add the following mapping into my vimrc: nnoremap <leader>sv :source $MYVIMRC | filetype detect<cr> This works in command mode, however, in the mapping I get: E475: ...
0
votes
0answers
20 views

What is required to update an autocmd?

From trial and error, to update the following command: autocmd FileType python nnoremap r ^i#<esc> I have to either: (re-)open a python file; or Run :so $MYVIMRC; then set ft=python in that ...
1
vote
1answer
43 views

Autocmds for particular filetypes

I'm trying to understand using the autocmd to modify properties for certain files. Here is a basic example I have in my vimrc: syntax on autocmd BufRead *.py syntax off However, when I then open up ...
-1
votes
1answer
96 views

Setting localleader

I've tried setting localleader using: :let localleader="]" And it seems to be 'working': :let localleader localleader ] However, when I try and run a command using localleader, it doesn'...
1
vote
1answer
110 views

Fortran Syntax Highlighting detecting apostrophes as Strings

I am using VIM 7.4 with syntax highlighting on some Fortran77 source code. One comment has a single apostrophe that never is repeated/closed (eg * Bert's bees), causing the remaining source code to ...
1
vote
0answers
26 views

Only close first fold when file is opened

When I open a file, I want to automatically fold all outer most folds, so no nesting. Here is what I currently have in my config: set fdm=syntax set foldnestmax=20 set foldenable " set foldlevel=99 ...
0
votes
0answers
31 views

Disable arrow keys in insert mode

I am trying to disable the arrow keys in the vimrc (previously I was doing it by doing a no-op on the keyboard itself): "Disable arrow keys inoremap <Left> <Nop> However, it seems to be ...
8
votes
3answers
648 views

Convert a search to a command in Vim

Often I will do a search to find things in Vim, such as: /-some-regex-here And after seeing what if grabs and iterating through a few of the results, I want to do a find-replace. Is there a way to ...
0
votes
1answer
48 views

Upper-case current word at word bounaries

If I am at the end of a word and I try and uppercase the inner word, it only uppercases the last letter of the word. For example: hello| <-- cursor is at the end of the word gUiw only applies on ...
0
votes
1answer
25 views

Execution of commands in vimrc/vimscript

If I add a command into my vimrc, such as: :echom "Hello" When I then open vim, I get the following: LA-DEV-IM-MM:Avails david$ vim new Hello! Press ENTER or type command to continue To better my ...
0
votes
2answers
84 views

Shortcut based on filetype

I would like to do the following remap: :inoremap <Option-Space> &nbsp; In other words, pressing option-space would add an html-escaped space. How could this be done, so that it only works ...
1
vote
1answer
162 views

How to open directory in toggled netrw window?

I've toggled netrw explorer window by adding the following commands found in an answer posted to this question to the vimrc file. let g:NetrwIsOpen=0 function! ToggleNetrw() if g:NetrwIsOpen ...
0
votes
1answer
61 views

How to bind these keys to prevent recursive binding in Vim?

I have been trying to do :noremap j k and :noremap k j which works but instead of going up it goes slanted up and down. I want j to move up and k to move down which is opposite in vim. I also tried :...
0
votes
0answers
16 views

Change all “go-to mark” mappings

I find that: `` Is much more useful to me than: '' And same with: `. Vs: '. (Sorry for the odd code-formatting, I had trouble doing the ``-formatting inline) Is it possible to set a vimrc ...
0
votes
0answers
30 views

Installing clang_complete Errors

I tried to add the clang_complete plugin to my vim. https://github.com/xavierd/clang_complete After I added it, I get a large error page before I can open any C++ file. The autocomplete still does ...
3
votes
3answers
629 views

How to find plugin vimscript function definition?

Assume I am using some plugin function e.g. For vim-plug, I put this code in my .vimrc at the end call plug#end() How to find out where is this function plug#end() is located? from vimrc directly ...
0
votes
0answers
27 views

Vim indentation of dynamic html templates (jinja, django, etc.)

I was wondering if there was a way to get vim to indent dynamic html tags, as now they all seem 'flat' based on auto-indentation. Here is an example video. Basically I want it to treat an {% if %} ...
0
votes
0answers
95 views

Vim formatting in css

I am having a very difficult time formatting css in an html file. For example, here is how vim 'thinks' it should be formatted: That is, after the above css section, it gives it 8 indentations (??), ...
1
vote
1answer
100 views

Vim-surround with “onemore”

I have the following setting on: set ve+=onemore "allows us to go one-past the last character, emulating ctrl-e in normal programs This is helpful for a lot of navigations and other commands I ...
1
vote
3answers
46 views

Customizing Tabbing and backspace properties in vim

There are two features related to indenting that I find very helpful in Textmate, and I'm looking to find the closest thing in vim. First, I can tab to the correct level of indentation, especially in ...
1
vote
2answers
174 views

Using the expression register in vim

I've written the following python script to be called with a shortcut in vim: :imap <c-t> <c-r>=system('./script.py')<cr> It works, and it's quite cool. However, I'd like to ...
2
votes
0answers
149 views

Vim adding blank line after each line when pasting from clipboard

When I copy-paste multiple lines from clipboard into my vim, it inserts a blank line after every line. But when I copy in into a text editor first and then copy-paste it into vim, the blank lines are ...
4
votes
1answer
93 views

Vim ignoring a very long line

I have an html file that I am editing. It includes about 1MB of css and stuff from another site, which is all contained on one minified line, which I've folded: It also causes any jumps 'around' line ...
0
votes
2answers
45 views

Close another buffer that had same name on window split

Here some asciinema videos, notice that in the videos, when I open another file (plugins.vim) in split using Ctrl+v it will create buffer tab named plugins.vim in the left, but when I close the ...
1
vote
1answer
38 views

Why is “set autoindent” in my ~/.vimrc ignored when I open a file?

I have set autoindentation, but vim somehow ignores it because :set autoindent? says noautoindent however the last file to have set autoindent is really my vimrc file according to :verbose set ...
1
vote
1answer
115 views

Edit in .vimrc but it's not updated in .git

So I was editing my ~/.vimrc file from the home directory and saved it, but when I went to check whether it had been updated in the vimrc file (for git) which is located at /.vim/vimrc, it did not ...
2
votes
1answer
160 views

Is there a way to make `viw` to select the current word that contains `-`?

As title says, I try to select the whole word with viw but if the naming convention is aaa-b-ccc, then I can't do that with this command. I have tried viW but this will include other symbols too which ...
1
vote
1answer
59 views

vim input function with default value

I'm working a function to rename the visual selected text function! Rename() name = getline("'<")[getpos("'<")[2]-1:getpos("'>")[2]-1] let newname = input('rename the selection with: ...
1
vote
1answer
177 views

Nerdtree going to specific directory

Is it possible to go to a typed-in directory in Nerdtree (when already in it)? The below seems so common to do: $ cd ~/my/directory/here And with my current understanding of NerdTree it requires me ...
1
vote
1answer
55 views

NerdTree cd vs CD

I'm not quite sure of the difference between cd and CD in NERDTree. It seems to actually cd into a directory I have to do cdCD, so for me they are kind of mushed together. From the docs it says: CD --...
1
vote
2answers
66 views

Moving start of text to correct indentation

A lot of times in vim I will copy-paste in some text, and it will not be at the correct level of indentation. Here is a sort of example: Is there a command I can run on one or more lines (other than ...
1
vote
1answer
32 views

How to do vim -c “startinsert”

Is there a way to enter into vim in insert mode, for example doing something like: $ vim -c "startinsert" I'm using an Automator (applescript) and I'd like to be able to click the icon to open vim ...

1
4 5
6
7 8
28