When I open any .c file, I hope that function name will be present at statusline according to current cursor position.
set statusline=%<%F%h%m%r%h%w%y\ %{strftime(\"%Y/%m/%d-%H:%M\")}%=\ col:%c%V\ ascii:%b\ pos:%o\ lin:%l\,%L\ %P
plz let me know how to present function name at statusline on vim
I found the solution.
first, it need to ctag. and then below vim.tgz extract at home directory.
https://drive.google.com/file/d/1e5_j79GILRrUr4rn6W9OsQAvnR-7n0Ao/view?usp=sharing
thanks
Bryan
Related
A very simple question, is there some way to show constantly the current working directory at the bottom of the file opened by vim? Thanks.
Note this is a different question as here:
How can I permanently display the path of the current file in Vim?
There we want to show the full path of the current file viewed, but what I am thinking is to show both, maybe two lines on the bottom of file: one for full path currently viewed; the other for the current working directory. These two could be different as we can open a file that's not in the current working directory.
You can do it by adding these lines in your .vimrc
set laststatus=2
set statusline=%!getcwd()
The first setting is to configure statusline to be always visible, second one is to add a current working directory to statusline.
More on
:h laststatus
:h statusline
:h getcwd()
Edit: This is an answer to OP's changed question:
It is not possible to have two-line statusline (at least to my knowledge). But it is possible to add e.g. some formatting. So
set laststatus=2
set statusline=%F
set statusline+=%=
set statusline+=%{getcwd()}
To further study I recommend to read help I mentioned before. Also this question might be of some interest.
I have just add virtualenv to vim. I want to have the active virtualenv show in the statusline so I know which environment I am in.
From Virtualenv help
g:virtualenv_stl_format
Format string for the statusline
Example:
let g:virtualenv_stl_format = '[%n]'
To sue the statusline flag, this must appear in your 'statusline' setting
%{virtualenv#statusline()}
So I went searching for the statusline and found
writing a valid statusline
They are going way beyond what I am trying to do and I really don't understand. I just want to simply add %{virtualenv#statusline()} to whatever line it is I have now, how do I do that?
The plugin I am referencing is this one https://github.com/jmcantrell/vim-virtualenv#readme
In its simplest form, your statusline could be reduced to this line in your ~/.vimrc (note the =):
set statusline=%{virtualenv#statusline()}
If you want that information to be displayed at the end of your current statusline, paste the following line in your ~/.vimrc (note the +=):
set statusline+=%{virtualenv#statusline()}
Or to place it at the beginning (note the ^=):
set statusline^=%{virtualenv#statusline()}
If you want to place this information at some arbitrary position in your custom statusline, you'll simply need to edit the corresponding line(s) in your ~/.vimrc. But you already know how to do that since you already have a custom statusline, do you?
If you use the default statusline, you'll need to replicate it as per the example given in :help statusline:
set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
and place the virtualenv snippet at the desired location, say after the status flags:
set statusline=%<%f\ %h%m%r%{virtualenv#statusline()}%=%-14.(%l,%c%V%)\ %P
But all that is clearly explained in :help statusline.
I know CTRLg displays the current file you're working on. Is there a way to modify my .vimrc such that the filename/path is always displayed?
In your statusline, add a %F to display the full path:
:help statusline
" Add full file path to your existing statusline
set statusline+=%F
Note, %F will be the full path. To get a path relative to the working directory, use %f.
If your statusline is not already visible, you may first need to configure it to be always visible, via laststatus=2
set laststatus=2
See :help laststatus for what the options mean. Normally, the statusline may be hidden, or hidden unless multiple buffers are open, but I find it extremely useful to have on all the time with customizations like this, well worth giving up one screen line reserve for it.
set ls=2
add this in vimrc,
and you will see the file name at the bottom always.
I found 2 ways to display the file path in the Title bar of the gnome-terminal while editing a file with Vim.
The simpler (and better) way: Add the following line to your ~/.vimrc:
set title
Which will show you at the top:
filename.ext (~/path_to_directory_where_your_file_is/) - VIM
The more complicated way will show you the absolute file path. It's documented in a bit more detail in this blog post I recently wrote.
If you are using vim-airline, put in .vimrc:
let g:airline_section_c = '%<%F%m %#__accent_red#%{airline#util#wrap(airline#parts#readonly(),0)}%#__restore__#'
This is a modification of the airline default, changing %f by %F.
The only way I found to get the full path of the file I'm working in is: :echo expand('%:p'). You can re-map ctrl+g if you want, but I personally don't like shifting away from the standards too much. I've mapped F7 like so:
map <F7> <Esc>:echo expand('%:p')<Return>
I've always used :f, but the answer and links from #MichaelBerkowski are amazing!
:f shows the path, line count, modified state, current cursor position, and more...
I didn't know about CTRLG but it appears to be about the same.
The statusline is very powerful and handy I think. Strait out of the box it will display filename, cursor position and some flags. But you want to do the same as me and replace the filename-part with the full path to the file.
So while editing my .vimrc my statusline could look something like this as default:
.vimrc 26,16 7%
You could view your setting of the statusline with:
:set statusline?
But if you have not made any alterations and no module has changed it it would be empty. But by the examples in the help-section (:help statusline) you could find that the default is:
:set statusline=%<%f\ %h%m%r%=%-14.(%l,%c%V%)\ %P
So include this in your .vimrc and change %f to %F. I also added added the filetype flag (%y) to my statusline since I find it convenient. So my resulting configuration looks like this:
:set statusline=%<%F\ %h%m%r%y%=%-14.(%l,%c%V%)\ %P
And the result would look something like this:
~/.vimrc [vim] 26,16 7%
Good reading:
The documentation
An excellent book to learn the basics
There is lots here on stackoverflow!
PS. I run vim 7.3
If you want the path to include resolved symlinks, use the following:
set statusline +=%{resolve(expand('%:p'))}\ %*
To keep the '~' abbreviation for your home directory, include fnamemodify
set statusline +=%{fnamemodify(resolve(expand('%:p')),':~')}\ %*
I want to change default blue color of folders
How to set it?
:hi Directory guifg=#FF0000 ctermfg=red
If you want to customize file colors based on extension, I created this plugin. You can use it with vim-devicons, but If you don't have it, you can add this line to your .vimrc and it will highlight the filenames:
let g:NERDTreeFileExtensionHighlightFullName = 1
Not a heavy vim user, but, I think you can add the following to your .vimrc to highlight the folders/directories in Cyan
highlight Directory ctermfg=cyan
Have only tried this out in MacOS 10.14
NERDTree doesn't provide such an option but looking at the source
and reading about highlight you could come up with some customization.
I had found a .vimrc configuration that allowed me to simply type
:e <<characters_in_filename>>
and then tab and the path would expand out to :e full_path or show me a list of options if there are similarly named files in my current path.
Anyone know how to make this happen?
note: I'm aware of FuzzyFileFinder, Peepopen, and CommandT, this has just really been bothering me.
It's very similar to the functionality described in this google groups thread
As ZyX said, it sounds like you want find.
set wildmenu
set wildmode=longest:full
set path+=./**
If you type :find so<Tab>, it will complete with all files that start with so searching recursively from the current file's directory (not pwd). (<Tab> can be changed with wildchar.)
You may prefer this kind of completion:
set wildmode=list:longest
And you could add your often used roots to path if you don't want recursive from the current file's directory.
set path+=~/code/**
If you just want to recurse from the current directory, try the above wild settings and use:
:edit **/so<Tab>
For more on specifying filenames see :help {file} and for more on **, see :help starstar-wildcard.
Be sure that wildmenu is on and try :find command.